Skip to content

Commit ee99f63

Browse files
authored
Merge pull request #971 from plotly/js_exponents_example
replaced toy exponential example with real dataset
2 parents b4f78e3 + 3295f5a commit ee99f63

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

_posts/plotly_js/layout/axes/2015-04-09-axes-labels.html

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
---
22
name: Set and Style Axes Title Labels and Ticks
3-
plot_url: https://codepen.io/plotly/embed/4fc1a99f9b12b436dec0a0663a9cd323/?height=486&theme-id=15263&default-tab=result
3+
plot_url: https://codepen.io/plotly/embed/ZjOxXw/?height=500&theme-id=15263&default-tab=result
44
language: plotly_js
55
suite: axes
66
order: 0
77
sitemap: false
88
arrangement: horizontal
99
---
10-
var x = [0, 1, 2, 3, 4, 5, 6, 7, 8];
11-
var maxX = Math.max(...x);
12-
var trace1 = {
13-
x: x,
14-
y: x.map(x => maxX-x).map(x => x*1E10),
15-
type: 'scatter'
16-
};
17-
var trace2 = {
18-
x: x,
19-
y: x.map(x => x*1E10),
20-
type: 'scatter'
21-
};
22-
var data = [trace1, trace2];
10+
11+
12+
13+
14+
Plotly.d3.csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv", function(err, rows){
15+
function unpack(rows, key) {
16+
return rows.map(function(row) { return row[key]; });
17+
}
18+
19+
var x = unpack(rows, 'Date')
20+
var y = unpack(rows, 'AAPL.Volume')
21+
22+
var trace = {
23+
type: "scatter",
24+
mode: "lines",
25+
name: 'AAPL Volume',
26+
x: x,
27+
y: y,
28+
line: {color: 'grey'}
29+
}
30+
31+
var data = [trace];
32+
2333
var layout = {
34+
title: 'Volume of Apple Shares Traded',
2435
xaxis: {
2536
title: 'AXIS TITLE',
2637
titlefont: {
@@ -29,7 +40,7 @@
2940
color: 'lightgrey'
3041
},
3142
showticklabels: true,
32-
tickangle: 45,
43+
tickangle: 'auto',
3344
tickfont: {
3445
family: 'Old Standard TT, serif',
3546
size: 14,
@@ -56,4 +67,6 @@
5667
showexponent: 'all'
5768
}
5869
};
70+
5971
Plotly.newPlot('myDiv', data, layout);
72+
})

0 commit comments

Comments
 (0)