Skip to content

Commit eceb946

Browse files
authored
Merge pull request #379 from plotly/update-plotly-js-docs-3.1
Plotly.js 3.1 examples
2 parents 1db7a6e + 9f345d4 commit eceb946

File tree

7 files changed

+1081
-359
lines changed

7 files changed

+1081
-359
lines changed

_data/jsversion.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "3.0.1"
2+
"version": "3.1.0"
33
}

_data/plotschema.json

Lines changed: 925 additions & 357 deletions
Large diffs are not rendered by default.

_data/pyversion.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "6.2.0"
2+
"version": "6.3.0"
33
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Zero Line Layer
3+
language: plotly_js
4+
suite: axes
5+
order: 12
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
*New in 3.1*
10+
11+
By default, zero lines are displayed below traces. Set `zerolinelayer="above traces"` on an axis to display its zero line above traces.
12+
---
13+
var trace1 = {
14+
x: ['A', 'B', 'C', 'D', 'A'],
15+
y: [2, 0, 4, -3, 2],
16+
fill: 'toself',
17+
mode: 'none',
18+
fillcolor: 'lightpink',
19+
type: 'scatter'
20+
};
21+
22+
var data = [trace1];
23+
24+
var layout = {
25+
yaxis: {
26+
zerolinelayer: "above traces" // Change to "below traces" to see the difference
27+
}
28+
};
29+
30+
Plotly.newPlot('myDiv', data, layout);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Disabling Buttons for Specific Axes
3+
language: plotly_js
4+
suite: configuration
5+
order: 5.8
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
*New in 3.1*
10+
11+
Disabling the zoom in, zoom out, and autoscale buttons for specific axes is supported on cartesian axes using the `modebardisable` attribute. In the following example, the zoom in and zoom out buttons are disabled on the `xaxis`, meaning these buttons only zoom in and out on the `yaxis`. Disable the autoscale button using `modebardisable='autoscale'`. You can also disable both autoscaling and zoom buttons using `modebardisable='zoominout+autoscale'`.
12+
---
13+
var data = [{
14+
type: "scatter",
15+
mode: "lines+markers",
16+
x: ["2023-01-01", "2023-02-01", "2023-03-01", "2023-04-01", "2023-05-01", "2023-06-01"],
17+
y: [150, 160, 155, 170, 165, 180],
18+
name: "Google Stock Price"
19+
}];
20+
21+
var layout = {
22+
title: "Google Stock Price Over Time with Mode Bar Disabled",
23+
xaxis: {
24+
title: "Date",
25+
type: "date",
26+
// Try zooming in or out using the modebar buttons. These only apply to the yaxis in this example.
27+
modebardisable: "zoominout"
28+
},
29+
yaxis: {
30+
title: "Stock Price (USD)"
31+
}
32+
};
33+
34+
Plotly.newPlot("myDiv", data, layout);
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Custom Unified Hover Title
3+
language: plotly_js
4+
suite: hover
5+
order: 5
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
*New in 3.1*
10+
11+
Customize the title shown in unified hovermode by specifying `unifiedhovertitle.text`. The unified hover title is a template string that supports using variables from the data. Numbers are formatted using d3-format's syntax `%{variable:d3-format}`, for example `"Price: %{y:$.2f}"`. Dates are formatted using d3-time-format's syntax `%{variable|d3-time-format}`, for example `"Day: %{x|%A}"`.
12+
---
13+
var data = [
14+
{
15+
x: ['2020-01-01', '2020-02-01', '2020-03-01', '2020-04-01'],
16+
y: [150.25, 165.50, 142.75, 178.90],
17+
mode: 'lines+markers',
18+
name: 'Stock A',
19+
type: 'scatter'
20+
},
21+
{
22+
x: ['2020-01-01', '2020-02-01', '2020-03-01', '2020-04-01'],
23+
y: [85.30, 92.15, 88.45, 95.20],
24+
mode: 'lines+markers',
25+
name: 'Stock B',
26+
type: 'scatter'
27+
}
28+
];
29+
30+
var layout = {
31+
title: {
32+
text: "Stock Prices with Custom Unified Hover Title"
33+
},
34+
hovermode: 'x unified',
35+
xaxis: {
36+
title: 'Date',
37+
unifiedhovertitle: {
38+
text: '<b>%{x|%A, %B %d, %Y}</b>'
39+
}
40+
},
41+
yaxis: {
42+
title: 'Price (USD)',
43+
tickprefix: '$'
44+
}
45+
};
46+
47+
Plotly.newPlot('myDiv', data, layout);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Unified Hover Mode
3+
language: plotly_js
4+
suite: hover
5+
order: 4
6+
sitemap: false
7+
arrangement: horizontal
8+
markdown_content: |
9+
If "x unified" (or "y unified"), a single hoverlabel will appear for multiple points at the closest x- (or y-) coordinate within the `hoverdistance` with the caveat that no more than one hoverlabel will appear per trace.
10+
---
11+
var data = [
12+
{
13+
x: ['2020-01-01', '2020-02-01', '2020-03-01', '2020-04-01'],
14+
y: [10, 15, 12, 18],
15+
mode: 'markers+lines',
16+
name: 'Series A',
17+
hovertemplate: null,
18+
type: 'scatter'
19+
},
20+
{
21+
x: ['2020-01-01', '2020-02-01', '2020-03-01', '2020-04-01'],
22+
y: [8, 12, 16, 14],
23+
mode: 'markers+lines',
24+
name: 'Series B',
25+
hovertemplate: null,
26+
type: 'scatter'
27+
}
28+
];
29+
30+
var layout = {
31+
title: {
32+
text: "layout.hovermode='x unified'"
33+
},
34+
hovermode: 'x unified',
35+
xaxis: {
36+
title: 'Date'
37+
},
38+
yaxis: {
39+
title: 'Value'
40+
}
41+
};
42+
43+
Plotly.newPlot('myDiv', data, layout);

0 commit comments

Comments
 (0)