The Web Components bullet graph component allows for a linear and concise view of measures compared against a scale.
The Ignite UI for Web Components bullet graph component provides you with the ability to create attractive data presentations, replacing meters and gauges that are used on dashboards with simple yet straightforward and clear bar charts. A bullet graph is one of the most effective and efficient ways to present progress towards goals, good/better/best ranges, or compare multiple measurements in as little horizontal or vertical space as possible.
Web Components Bullet Graph Example
The following sample demonstrates how setting multiple properties on the same IgcBulletGraphComponent can transform it to completely different bullet graph.
<!DOCTYPE html><html><head><title>BulletGraphAnimation</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><divclass="options horizontal"><buttonid="animationButton1"class="options-button">Gauge Animation #1</button><buttonid="animationButton2"class="options-button">Gauge Animation #2</button><buttonid="animationButton3"class="options-button">Gauge Animation #3</button></div><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"maximum-value="120"value-brush="#4286f4"value="70"target-value-brush="#4286f4"target-value="90"target-value-breadth="10"interval="10"label-interval="10"label-extent="0.02"range-brushes ="#FF9800, #F96232, #C62828"range-outlines="#FF9800, #F96232, #C62828"scale-background-thickness="0"scale-background-brush="#dbdbdb"scale-background-outline="gray"></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.
The bullet graph supports one scale, one set of tick marks and one set of labels. The bullet graph component also has built-in support for animated transitions. This animation is easily customizable by setting the transitionDuration property.
The features of the bullet graph include configurable orientation and direction, configurable visual elements such as the needle, and more.
Dependencies
When installing the gauge package, the core package must also be installed.
The following code walks through creating a bullet graph component, and configuring a performance bar, comparative measure marker, and three comparative ranges on the scale.
The bullet graph can show two measures: performance value and target value.
Performance value is the primary measure displayed by the component and it is visualized as a bar that stretches along the length of the whole graph. The target value is a measure which the performance value compares against. It is displayed as a small block that runs perpendicular to the orientation of the performance bar.
<!DOCTYPE html><html><head><title>BulletGraphMeasures</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"maximum-value="100"value="50"value-brush="DodgerBlue"value-stroke-thickness="1"value-inner-extent="0.5"value-outer-extent="0.65"target-value="80"target-value-breadth="10"target-value-brush="LimeGreen"target-value-outline="LimeGreen"target-value-stroke-thickness="1"target-value-inner-extent="0.3"target-value-outer-extent="0.85"scale-background-brush = "#e5e5e5"scale-background-outline = "#e5e5e5"backing-brush = "#f7f7f7"backing-outline = "#bfbfbf"tick-stroke-thickness = "1.5" ></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Highlight Value
The bullet graph's performance value can be further modified to show progress represented as a highlighted value. This will make the value appear with a lower opacity. A good example is if value is 50 and highlightValue is set to 25. This would represent a performance of 50% regardless of what the value of targetValue is set to. To enable this first set highlightValueDisplayMode to Overlay and then apply a highlightValue to something lower than value.
<!DOCTYPE html><html><head><title>BulletGraphHighlightNeedle</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"maximum-value="100"value="70"interval="10"target-value="90"label-interval="10"label-extent="0.025"labels-pre-terminal="0"labels-post-initial="0"highlight-value-display-mode="Overlay"highlight-value="25" ></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Comparative Ranges
The ranges are visual elements that highlight a specified range of values on a scale. Their purpose is to visually communicate the qualitative state of the performance bar measure, illustrating at the same time the degree to which it resides within that state.
<!DOCTYPE html><html><head><title>BulletGraphRanges</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"value="80"interval="10"maximum-value="100"target-value="90"range-brushes ="#C62828, #F96232, #FF9800"range-outlines="#C62828, #F96232, #FF9800"><igc-linear-graph-rangename="range1"start-value="0"end-value="40"inner-start-extent="0.075"inner-end-extent="0.075"outer-start-extent="0.95"outer-end-extent="0.95" ></igc-linear-graph-range><igc-linear-graph-rangename="range2"start-value="40"end-value="70"inner-start-extent="0.075"inner-end-extent="0.075"outer-start-extent="0.95"outer-end-extent="0.95" ></igc-linear-graph-range><igc-linear-graph-rangename="range3"start-value="70"end-value="100"inner-start-extent="0.075"inner-end-extent="0.075"outer-start-extent="0.95"outer-end-extent="0.95" ></igc-linear-graph-range></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Tick Marks
The tick marks serve as a visual division of the scale into intervals in order to increase the readability of the bullet graph.
Major tick marks – The major tick marks are used as primary delimiters on the scale. The frequency they appear at, their extents and style can be controlled by setting their corresponding properties.
Minor tick marks – The minor tick marks represent helper tick marks, which might be used to additionally improve the readability of the scale and can be customized in a way similar to the major ones.
<!DOCTYPE html><html><head><title>BulletGraphTickmarks</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphheight="80px"width="100%"minimum-value="0"value="70"interval="10"maximum-value="100"target-value="90"tick-brush="DodgerBlue"ticks-pre-terminal="0"ticks-post-initial="0"tick-stroke-thickness="2"tick-start-extent="0.2"tick-end-extent="0.075"minor-tick-count="4"minor-tick-brush="DarkViolet"minor-tick-end-extent="0.1"minor-tick-start-extent="0.2"minor-tick-stroke-thickness="1" ></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
<!DOCTYPE html><html><head><title>BulletGraphLabels</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"value="70"interval="10"maximum-value="100"target-value="90"label-interval="10"label-extent="0.025"labels-pre-terminal="0"labels-post-initial="0"font-brush="DodgerBlue"font="11px Verdana"></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Backing
The backing element represents background and border of the bullet graph component. It is always the first element rendered and all the rest of elements such as labels, and tick marks are overlaid on top of it.
<!DOCTYPE html><html><head><title>BulletGraphBackground</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"value="70"interval="10"maximum-value="100"target-value="90"backing-brush="#bddcfc"backing-outline="DodgerBlue"backing-stroke-thickness="4"backing-inner-extent="0"backing-outer-extent="1"></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Scale
The scale is visual element that highlights the full range of values in the gauge. You can customize appearance and shape of the scale. The scale can also be inverted (using isScaleInverted property) and all labels will be rendered from right-to-left instead of left-to-right.
<!DOCTYPE html><html><head><title>BulletGraphScale</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css"type="text/css" /></head><body><divid="root"><divclass="container sample center" ><igc-bullet-graphid="gauge"height="80px"width="100%"minimum-value="0"value="70"interval="10"maximum-value="100"target-value="90"is-scale-inverted="false"scale-background-brush="DodgerBlue"scale-background-outline="Red"scale-background-thickness="2"scale-start-extent="0.05"scale-end-extent="0.95" ></igc-bullet-graph></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Summary
For your convenience, all above code snippets are combined into one code block below that you can easily copy to your project and see the bullet graph with all features and visuals enabled.