Create Gauge and Bullet Charts in Excel With Python
Gauge and bullet charts show one KPI against a target. My Excel template collected the chart settings in a sheet, and a button ran a Python script that drew the chart with Plotly and saved it as an image or interactive HTML file. The template download is gone, so this post includes tested Plotly code that does the same job.
How the template worked
The template was a settings sheet plus a Generate button. Clicking the button ran a Python script, which read the settings and created the chart. Switching between a gauge and a bullet chart only meant changing the shape setting.

Every setting applied to both chart types:
- Title: text, alignment, size and font family.
- Values: the value of the inner bar, the threshold, the maximum and a reference value for the delta. A mode setting hides the number if you only want the chart.
- Colors: RGB codes, hex values or color names such as red or green.
- Axis: tick marks, or no axis at all.
- Other: font size, figure height, threshold width, output file name and format.
A wrong input, such as an invalid hex code, showed a message box and wrote an error log file, so you could see which setting broke the chart.
Build the charts with Plotly
Both charts are the same Plotly object, go.Indicator, with a different gauge shape: "angular" for a gauge and "bullet" for a bullet chart. The script below reads its settings from a sheet with two columns, Setting and Value, and saves an interactive HTML file.
import pandas as pd
import plotly.graph_objects as go
def indicator_chart(title, value, target, max_value, shape="angular"):
fig = go.Figure(go.Indicator(
mode="number+gauge+delta",
value=value,
delta={"reference": target},
title={"text": title},
# a bullet chart needs room on the left for its title
domain={"x": [0.3, 1] if shape == "bullet" else [0, 1], "y": [0, 1]},
gauge={
"shape": shape, # "angular" draws a gauge, "bullet" a bullet chart
"axis": {"range": [0, max_value]},
"bar": {"color": "#1f4e79"},
"steps": [
{"range": [0, target * 0.6], "color": "#e6e6e6"},
{"range": [target * 0.6, target], "color": "#c8c8c8"},
],
"threshold": {"line": {"color": "red", "width": 3}, "value": target},
},
))
fig.update_layout(height=250 if shape == "bullet" else 400)
return fig
# Two columns in the sheet: Setting and Value
settings = pd.read_excel("indicator.xlsx", sheet_name="Settings", index_col=0)["Value"]
fig = indicator_chart(
title=settings["title"],
value=float(settings["value"]),
target=float(settings["target"]),
max_value=float(settings["max_value"]),
shape=settings["shape"],
)
fig.write_html("indicator.html") # interactive, no extra install
The sheet needs the rows title, shape, value, target and max_value. With a value of 72 against a target of 80, the gauge shows 72 with a red delta of -8 and a red line at the target. The two grey steps mark the poor and OK ranges, here up to 60% of the target and up to the target. Change them to your own thresholds.
For a PNG or PDF instead of HTML, use fig.write_image("indicator.png"). That needs the Kaleido package. Current Plotly versions need Kaleido 1.0 or newer, which renders with a Chrome or Chromium installed on your machine. If you have none, the plotly_get_chrome command installs one. HTML export needs neither.
Run it from Excel
The template ran the script from VBA with the path to your Python installation, which you entered in a settings cell. That way it worked with whichever Python environment had Plotly and pandas installed.

To find the path, type where python in the command prompt. Install the packages with pip install plotly pandas openpyxl. The VBA side is the same technique I explain in running a Python script from Excel with VBA. In the script, wrap the chart code in a try/except block that writes the error to a log file, so a bad setting does not fail silently.
I built a sister template with the same VBA plus Python setup for interactive waterfall charts. For animated KPI circles there is the Pyecharts liquid chart. If you want bullet charts without Python at all, my Excel add-in Deltaline draws them, KPIs against target and ranges, directly from a table in Excel.
