Skip to content

Commit 2975fd8

Browse files
committed
replaced toy exponential example with real dataset
1 parent b4f78e3 commit 2975fd8

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

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

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
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/michaelbabyn/embed/KBMmov/?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];
23-
var layout = {
10+
11+
12+
13+
14+
Plotly.d3.csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv", function(err, rows){
15+
16+
function unpack(rows, key) {
17+
return rows.map(function(row) { return row[key]; });
18+
}
19+
20+
var x = unpack(rows, 'Date')
21+
var y = unpack(rows, 'AAPL.Volume')
22+
23+
24+
var trace = {
25+
type: "scatter",
26+
mode: "lines",
27+
name: 'AAPL Volume',
28+
x: x,
29+
y: y,
30+
line: {color: 'grey'}
31+
}
32+
33+
var data = [trace];
34+
var layout = {
35+
title: 'Volume of Apple Shares Traded',
2436
xaxis: {
2537
title: 'AXIS TITLE',
2638
titlefont: {
@@ -56,4 +68,6 @@
5668
showexponent: 'all'
5769
}
5870
};
71+
5972
Plotly.newPlot('myDiv', data, layout);
73+
})

0 commit comments

Comments
 (0)