Visualization in A 1x6 Bullet Graph Layout
A bullet graph effectively compares a primary performance measure against related measures and displays it within the context of qualitative ranges, such as poor, satisfactory, and good. It also includes a performance marker to provide immediate context and enable quick assessment of progress against a specific target or benchmark. This visualization offers a concise yet rich display of key performance indicators. Bullet graphs are particularly useful in business intelligence and performance management, where they can replace traditional gauges and meters. They are designed to be space-efficient, allowing for the display of multiple measures in a compact format. This makes them ideal for dashboards and reports where space is limited but clarity is essential.
<html>
<head>
<!-- Include the CanvasXpress library in your HTML file -->
<link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
<script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
</head>
<body>
<!-- Create a canvas element for the chart with the desired dimensions -->
<div>
<canvas id="canvasId" width="600" height="600"></canvas>
</div>
<!-- Create a script to initialize the chart -->
<script>
// Use a data frame (2D-array) for the graph
var data = [
[ "Id", "V1", "V2", "V3", "V4", "V5"],
[ "S1", 19, 15, 35, 70, 46],
[ "S2", 25, 15, 35, 70, 52],
[ "S3", 52, 15, 35, 70, 42],
[ "S4", 57, 20, 40, 70, 63],
[ "S5", 31, 20, 40, 70, 56],
[ "S6", 42, 20, 40, 70, 51 ]
];
// Create the configuration for the graph
var config = {
"colors" : ["#3F3F3F"],
"graphOrientation" : "vertical",
"graphType" : "Bullet",
"showDataValues" : true,
"smpTextRotate": "90",
"xAxis" : ["V1"],
"rangeStack": ["V2", "V3", "V4"],
"rangeColors": ["#945D55", "#C4A285", "#EBE7DE"],
"bulletTargetVarName": "V5",
"bulletTargetVarColor": "#3F3F3F",
"segregateSamplesBy" : ["sample"],
"layoutTopology" : "1X6",
"layoutAdjust": true,
"stripShow": false,
"xAxisTextScaleFontFactor": 0.6
}
// Event used to create graph (optional)
var events = false
// Call the CanvasXpress function to create the graph
var cX = new CanvasXpress("canvasId", data, config, events);
</script>
</body>
</html>
<html>
<head>
<!-- Include the CanvasXpress library in your HTML file -->
<link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
<script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
</head>
<body>
<!-- Create a canvas element for the chart with the desired dimensions -->
<div>
<canvas id="canvasId" width="600" height="600"></canvas>
</div>
<!-- Create a script to initialize the chart -->
<script>
// Create the data for the graph
var data = {
"y": {
"data": [
[ 19, 25, 52, 57, 31, 42 ],
[ 15, 15, 15, 20, 20, 20 ],
[ 35, 35, 35, 40, 40, 40 ],
[ 70, 70, 70, 70, 70, 70 ],
[ 46, 52, 42, 63, 56, 51 ]
],
"smps": [ "S1", "S2", "S3", "S4", "S5", "S6" ],
"vars": [ "V1", "V2", "V3", "V4", "V5" ]
}
}
// Create the configuration for the graph
var config = {
"colors" : ["#3F3F3F"],
"graphOrientation" : "vertical",
"graphType" : "Bullet",
"showDataValues" : true,
"smpTextRotate": "90",
"xAxis" : ["V1"],
"rangeStack": ["V2", "V3", "V4"],
"rangeColors": ["#945D55", "#C4A285", "#EBE7DE"],
"bulletTargetVarName": "V5",
"bulletTargetVarColor": "#3F3F3F",
"segregateSamplesBy" : ["sample"],
"layoutTopology" : "1X6",
"layoutAdjust": true,
"stripShow": false,
"xAxisTextScaleFontFactor": 0.6
}
// Event used to create graph (optional)
var events = false
// Call the CanvasXpress function to create the graph
var cX = new CanvasXpress("canvasId", data, config, events);
</script>
</body>
</html>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-bullet-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
bulletTargetVarColor="#3F3F3F",
bulletTargetVarName="V5",
colors=list("#3F3F3F"),
graphOrientation="vertical",
graphType="Bullet",
layoutAdjust=TRUE,
layoutTopology="1X6",
rangeColors=list("#945D55", "#C4A285", "#EBE7DE"),
rangeStack=list("V2", "V3", "V4"),
segregateSamplesBy=list("sample"),
showDataValues=TRUE,
smpTextRotate=90,
stripShow=FALSE,
xAxis=list("V1"),
xAxisTextScaleFontFactor=0.6
)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import show_in_browser
if __name__ == "__main__":
# Define the chart with its data and configuration
chart: CanvasXpress = CanvasXpress(
render_to = "bullet2",
data = {
"y": {
"data": [
[19, 25, 52, 57, 31, 42],
[15, 15, 15, 20, 20, 20],
[35, 35, 35, 40, 40, 40],
[70, 70, 70, 70, 70, 70],
[46, 52, 42, 63, 56, 51]
],
"smps": ["S1", "S2", "S3", "S4", "S5", "S6"],
"vars": ["V1", "V2", "V3", "V4", "V5"]
}
},
config = {
"colors": ["#3F3F3F"],
"graphOrientation": "vertical",
"graphType": "Bullet",
"showDataValues": True,
"smpTextRotate": "90",
"xAxis": ["V1"],
"rangeStack": ["V2", "V3", "V4"],
"rangeColors": ["#945D55", "#C4A285", "#EBE7DE"],
"bulletTargetVarName": "V5",
"bulletTargetVarColor": "#3F3F3F",
"segregateSamplesBy": ["sample"],
"layoutTopology": "1X6",
"layoutAdjust": True,
"stripShow": False,
"xAxisTextScaleFontFactor": 0.6
},
width = 600,
height = 600
)
# Display the chart in its own Web page
show_in_browser(chart)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph
graph(
CanvasXpress(
render_to = "bullet2",
data = {
"y": {
"data": [
[19, 25, 52, 57, 31, 42],
[15, 15, 15, 20, 20, 20],
[35, 35, 35, 40, 40, 40],
[70, 70, 70, 70, 70, 70],
[46, 52, 42, 63, 56, 51]
],
"smps": ["S1", "S2", "S3", "S4", "S5", "S6"],
"vars": ["V1", "V2", "V3", "V4", "V5"]
}
},
config = {
"colors": ["#3F3F3F"],
"graphOrientation": "vertical",
"graphType": "Bullet",
"showDataValues": True,
"smpTextRotate": "90",
"xAxis": ["V1"],
"rangeStack": ["V2", "V3", "V4"],
"rangeColors": ["#945D55", "#C4A285", "#EBE7DE"],
"bulletTargetVarName": "V5",
"bulletTargetVarColor": "#3F3F3F",
"segregateSamplesBy": ["sample"],
"layoutTopology": "1X6",
"layoutAdjust": True,
"stripShow": False,
"xAxisTextScaleFontFactor": 0.6
},
width = 600,
height = 600
)
)





