Skip to content

Commit f5b1426

Browse files
authored
Merge pull request #1440 from plotly/indicator2
modifications on indicator page
2 parents fb6aef4 + b707575 commit f5b1426

10 files changed

+131
-165
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
---
2-
name: Showing Information Above Your Chart
2+
name: Showing Information above Your Chart
33
plot_url: https://codepen.io/plotly/embed/OKpLYv/?height=600&theme-id=15263&default-tab=result
44
language: plotly_js
55
suite: indicator
6-
order: 3
6+
order: 4
77
sitemap: false
88
arrangement: horizontal
99
markdown_content: |
1010

1111
Another interesting feature is that indicator trace sits above the other traces (even the 3d ones). This way, it can be easily used as an overlay as demonstrated below:
1212
---
13-
var data = [{domain: {y: [0, 1], x: [0.25, 0.75]}, title: {"text": "Users online"},
14-
type: "indicator", mode: "number+delta", delta: {"reference": 512, "valueformat": ".0f"},
15-
ticker: {showticker: true}, vmax: 500, value: 492}, {name: "Users online",
16-
y: [325, 324, 405, 400, 424, 404, 417, 432, 419, 394, 410, 426, 413, 419, 404, 408, 401, 377, 368, 361, 356, 359, 375, 397, 394, 418, 437, 450, 430, 442, 424, 443, 420, 418, 423, 423, 426, 440, 437, 436, 447, 460, 478, 472, 450, 456, 436, 418, 429, 412, 429, 442, 464, 447, 434, 457, 474, 480, 499, 497, 480, 502, 512, 492]}];
13+
var data = [
14+
{
15+
type: "indicator", mode: "number+delta", value: 492,
16+
delta: {"reference": 512, "valueformat": ".0f"}, title: {"text": "Users online"},
17+
ticker: {showticker: true}, vmax: 500, domain: {y: [0, 1], x: [0.25, 0.75]}
18+
},{
19+
y: [325, 324, 405, 400, 424, 404, 417, 432, 419, 394, 410, 426, 413, 419, 404, 408, 401, 377, 368, 361, 356, 359, 375, 397, 394, 418, 437, 450, 430, 442, 424, 443, 420, 418, 423, 423, 426, 440, 437, 436, 447, 460, 478, 472, 450, 456, 436, 418, 429, 412, 429, 442, 464, 447, 434, 457, 474, 480, 499, 497, 480, 502, 512, 492]
20+
}];
1721

18-
var layout = {width: 500, height: 500, xaxis: {range: [0, 62]}};
19-
20-
Plotly.newPlot(gd,data,layout);
22+
var layout = {width: 600, height: 450, xaxis: {range: [0, 62]}};
23+
Plotly.newPlot(gd,data,layout);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: A Single Angular Gauge Chart
3+
plot_url: https://codepen.io/plotly/embed/xvgeVj/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: indicator
6+
order: 2
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
---
11+
Plotly.newPlot(gd,data,layout);
12+
13+
var data = [type: "indicator", mode: "gauge+number"}, value: 450,
14+
title: {text: "Speed"}, {domain: {x: [0, 1], y: [0, 1]}];
15+
16+
var layout = {width: 600, height: 400};
17+
Plotly.newPlot(gd,data,layout);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Data Cards / Big Numbers
3+
plot_url: https://codepen.io/plotly/embed/bXabjP/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: indicator
6+
order: 4.1
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
Data card helps to display more contextual information about the data. Sometimes one number is all you want to see in a report, such as total sales, annual revenue, etc. This example shows how to visualize these big numbers:
12+
---
13+
var data = [
14+
{type: "indicator", mode: "number+delta", value: 400, number: {prefix: "$"},
15+
delta: {position: "top", reference: 320}, domain: {x: [0, 1], y: [0, 1]}}];
16+
17+
var layout = {paper_bgcolor: "lightgray", width: 600, height: 200,
18+
margin: {"t": 0, "b": 0, "l": 0, "r": 0}}
19+
20+
Plotly.newPlot(gd,data,layout);

_posts/plotly_js/financial/indicator1/2019-07-29-indicator_grid_template2.html renamed to _posts/plotly_js/financial/indicator1/2019-07-29-bullet.html

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
plot_url: https://codepen.io/plotly/embed/EqZBWg/?height=600&theme-id=15263&default-tab=result
44
language: plotly_js
55
suite: indicator
6-
order: 2
6+
order: 3
77
sitemap: false
88
arrangement: horizontal
99
markdown_content: |
1010

1111
The equivalent of above "angular gauge":
1212

1313
---
14-
var data = [{domain: {x: [0.20, 1], y: [0.25, 0.92]},
15-
title: {text: "Avg order size"},
16-
type: "indicator", mode: "number+gauge", gauge: {shape: "bullet"}, value: 220}];
17-
18-
var layout = {width: 500, height: 250, shapes: [{type: "rect", x0: 0.20, x1: 1, y0: 0.25, y1: 0.92}]};
14+
var data = [
15+
type: "indicator", mode: "number+gauge", gauge: {shape: "bullet"},
16+
value: 220}, {domain: {x: [0, 1], y: [0, 1]}, title: {text: "Avg order size"}];
1917

18+
var layout = {width: 600, height: 100};
2019
Plotly.newPlot(gd,data,layout);

_posts/plotly_js/financial/indicator1/2019-07-29-indicator_grid_template.html

-43
This file was deleted.

_posts/plotly_js/financial/indicator1/2019-07-29-indicator_grid_template4.html

-37
This file was deleted.

_posts/plotly_js/financial/indicator1/2019-07-29-indicator_grid_template5.html

-44
This file was deleted.

_posts/plotly_js/financial/indicator1/2019-07-29-indicator_grid_template6.html

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
name: Overview
3+
plot_url: https://codepen.io/plotly/embed/ymMWRR/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: indicator
6+
order: 1
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
In this tutorial we introduce a new trace named "Indicator". The purpose of "indicator" is to visualize a single value specified by the "value" attribute.
12+
Three distinct visual elements are available to represent that value: number, delta and gauge. Any combination of them can be specified via the "mode" attribute.
13+
Top-level attributes are:
14+
* value: the value to visualize
15+
* mode: which visual elements to draw
16+
* align: how to align number and delta (left, center, right)
17+
* domain: the extent of the figure
18+
19+
Then we can configure the 3 different visual elements via their respective container:
20+
* number is simply a representation of the number in text. It has attributes:
21+
* valueformat: to format the number
22+
* prefix: a string before the number
23+
* suffix: a string after the number
24+
* font.(family|size): to control the font
25+
26+
"delta" simply displays the difference between the value with respect to a reference. It has attributes:
27+
* reference: the number to compare the value with
28+
* relative: whether that difference is absolute or relative
29+
* valueformat: to format the delta
30+
* (increasing|decreasing).color: color to be used for positive or decreasing delta
31+
* (increasing|decreasing).symbol: symbol displayed on the left of the delta
32+
* font.(family|size): to control the font
33+
* position: position relative to `number` (either top, left, bottom, right)
34+
35+
Finally, we can have a simple title for the indicator via `title` with 'text' attribute which is a string, and 'align' which can be set to left, center, and right.
36+
There are two gauge types: [angular](https://plot.ly/javascript/gauge-charts/) and [bullet](https://plot.ly/javascript/bullet-charts/). Here is a combination of both shapes (angular, bullet), and different modes (guage, delta, and value):
37+
---
38+
var data = [
39+
{type: "indicator", value: 200, delta: {reference: 160},
40+
gauge: {axis: {visible: false, range: [0, 200]}}, domain: {row: 0, column: 0}},
41+
{type: "indicator", value: 120, gauge: {shape: "bullet", axis: {visible: false,
42+
range: [-200, 200]}}, domain: {x: [0.05, 0.5], y: [0.15, 0.35]}},
43+
{type: "indicator", mode: "number+delta", value: 300, domain: {row: 0, column: 1}},
44+
{type: "indicator", mode: "delta", value: 40, domain: {row: 1, column: 1}}];
45+
46+
var layout = {width: 600, height: 400, margin: {t: 25, b: 25, l: 25, r: 25},
47+
grid: {rows: 2, columns: 2, pattern: "independent"}, template: {
48+
data: {indicator: [{title: {text: "Speed"}, mode: "number+delta+gauge",
49+
delta: {reference: 90}}]}}};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name:
3+
plot_url: https://codepen.io/plotly/embed/PMppGM/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: indicator
6+
order: 7
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
It's possible to display several numbers
12+
---
13+
var data = [
14+
{
15+
type: "indicator", mode: "number+delta", value: 200, domain: {x: [0, 0.5],
16+
y: [0, 0.5]}, delta: {reference: 400, relative: true, position: "top"}},
17+
{
18+
type: "indicator", mode: "number+delta", value: 350,
19+
delta: {reference: 400, relative: true}, domain: {x: [0, 0.5], y: [0.5, 1]}},
20+
{
21+
type: "indicator", mode: "number+delta", value: 450,
22+
title: {"text": "Accounts<br><span style='font-size:0.8em;color:gray'>Subtitle</span><br><span style='font-size:0.8em;color:gray'>Subsubtitle</span>"},
23+
delta: {reference: 400, relative: true}, domain: {x: [0.6, 1], y: [0, 1]}}];
24+
25+
var layout = {width: 600, height: 400, margin: {t: 25, r: 25, l: 25, b: 25}};
26+
27+
Plotly.newPlot(gd,data,layout);
28+

0 commit comments

Comments
 (0)