Skip to content

Commit 3acf275

Browse files
author
mahdis-z
committed
bullet charts
1 parent 5f06da5 commit 3acf275

5 files changed

+124
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: JavaScript Graphing Library D3.js-based Bullet Charts| Examples | Plotly
3+
name: Bullet Charts
4+
permalink: javascript/bullet-charts/
5+
description: How to make a D3.js-based bullet chart in javascript.
6+
layout: user-guide
7+
thumbnail: thumbnail/bullet.png
8+
language: plotly_js
9+
page_type: example_index
10+
has_thumbnail: true
11+
display_as: financial
12+
order: 8
13+
redirect_from: javascript-graphing-library/bullet-charts
14+
---
15+
{% assign examples = site.posts | where:"language","plotly_js" | where:"suite","bullet-charts" | sort: "order" %}
16+
{% include auto_examples.html examples=examples %}
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
name: Add Steps, and Threshold
3+
plot_url: https://codepen.io/plotly/embed/gVvazV/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: bullet-charts
6+
order: 2
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
Below is the same example using "steps" attribute, which is shown as shading, and "threshold" to determine boundaries that visually alert you if the value cross a defined threshold.
12+
---
13+
var data = [{
14+
type: "indicator", mode: "number+gauge+delta", value: 220,
15+
domain: {x: [0, 1], y: [0, 1]}, title: {text :"<b>Profit</b>"},
16+
delta: {reference: 200}, gauge: {shape: "bullet", axis: {range: [null, 300]},
17+
threshold: {line: {color: "red", width: 2}, thickness: 0.75, value: 280},
18+
steps: [{range: [0, 150], color: "lightgray"}, {range: [150, 250], color: "gray"}]}
19+
}];
20+
21+
var layout = {width: 600, height: 250};
22+
var config = {responsive: true};
23+
24+
Plotly.newPlot(gd,data,layout,config);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Basic Bullet Charts
3+
plot_url: https://codepen.io/plotly/embed/EqZBWg/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: bullet-charts
6+
order: 1
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
Stephen Few's Bullet Chart was invented to replace dashboard [gauges](https://plot.ly/javascript/gauge-charts/) and meters, combining both types of charts into simple bar charts with qualitative bars (steps), quantitative bar (bar) and performance line (threshold); all into one simple layout.
12+
Steps typically are broken into several values, which is defined with an array. The bar represent the actual value that a particular variable reached, and the threshold usually indicate a goal point relative to the value achieved by the bar. See [indicator page](https://plot.ly/javascript/gauge-charts/) for more detail.
13+
---
14+
var data = [{
15+
type: "indicator", mode: "number+gauge+delta", gauge: {shape: "bullet"},
16+
delta: {reference: 300}, value: 220, domain: {x: [0, 1], y: [0, 1]},
17+
title: {text: "Profit"}}];
18+
19+
var layout = {width: 600, height: 250};
20+
Plotly.newPlot(gd,data,layout);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Custom Bullet Chart
3+
plot_url: https://codepen.io/plotly/embed/OKQVjE/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: bullet-charts
6+
order: 3
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
The following example shows how to customize your charts. For more information about all possible options check our [reference page](https://plot.ly/javascript/reference/#indicator).
12+
---
13+
var data = [{
14+
type: "indicator", mode: "number+gauge+delta", value: 220,
15+
domain: {x: [0, 1], y: [0, 1]}, delta: {reference: 280, position: "top"},
16+
title: {text :"<b>Profit</b><br><span style='color: gray; font-size:0.8em'>U.S. $</span>",
17+
font: {"size": 14}}, gauge: {shape: "bullet", axis: {range: [null, 300]},
18+
threshold: {line: {color: "red", width: 2}, thickness: 0.75, value: 270}, bgcolor: "white",
19+
steps: [{range: [0, 150], color: "cyan"}, {range: [150, 250], color: "royalblue"}],
20+
bar: {color: "darkblue"}}}];
21+
22+
var layout = {width: 600, height: 230};
23+
var config = {responsive: true};
24+
25+
Plotly.newPlot(gd,data,layout,config);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Multi Bullet
3+
plot_url: https://codepen.io/plotly/embed/xvYGyq/?height=600&theme-id=15263&default-tab=result
4+
language: plotly_js
5+
suite: bullet-charts
6+
order: 4
7+
sitemap: false
8+
arrangement: horizontal
9+
markdown_content: |
10+
11+
Bullet charts can be stacked for comparing several values at once as illustrated below:
12+
---
13+
var data = [{
14+
type: "indicator", mode: "number+gauge+delta", value: 180,
15+
delta: {reference: 200}, domain: {x: [0.25, 1], y: [0.08, 0.25]},
16+
title: {text: "Revenue"}, gauge: {shape: "bullet", axis: {range: [null, 300]},
17+
threshold: {line: {color: "black", width: 2}, thickness: 0.75, value: 170},
18+
steps: [{range: [0, 150], color: "gray"}, {range: [150, 250],
19+
color: "lightgray"}], bar: {color: "black"}}
20+
},{
21+
type: "indicator", mode: "number+gauge+delta", value: 35,
22+
delta: {reference: 200}, domain: {x: [0.25, 1], y: [0.4, 0.6]},
23+
title: {text: "Profit"}, gauge: {shape: "bullet", axis: {range: [null, 100]},
24+
threshold: {line: {color: "black", width: 2}, thickness: 0.75, value: 50},
25+
steps: [{range: [0, 25], color: "gray"}, {range: [25, 75], color: "lightgray"}],
26+
bar: {color: "black"}}
27+
}, {
28+
type: "indicator", mode: "number+gauge+delta", value: 220,
29+
delta: {reference: 200}, domain: {x: [0.25, 1], y: [0.7, 0.9]},
30+
title: {text :"Satisfaction"}, gauge: {shape: "bullet", axis: {range: [null, 300]},
31+
threshold: {line: {color: "black", width: 2}, thickness: 0.75, value: 210},
32+
steps: [{range: [0, 150], color: "gray"}, {range: [150, 250], color: "lightgray"}],
33+
bar: {color: "black"}}
34+
}];
35+
36+
var layout = {width: 600, height: 250, margin: {t: 10, "r": 25, "l": 25, "b": 10}};
37+
Plotly.newPlot(gd,data,layout);
38+

0 commit comments

Comments
 (0)