Excel and Google Sheets Charts and Dashboards
skillBuild charts, sparklines, slicers and dashboards inside Excel or Google Sheets, or generate a workbook with charts from Python. Use for sheet dashboards.
agents that use this skill
instructions
Overview
Use this skill when a chart, sparkline or dashboard is built inside Excel or Google Sheets, or when a workbook with charts is generated from Python. The outcome is a workbook where each chart answers one question, still works after rows are added, and can be handed to someone who was not there. Formulas, lookups and pivot table setup are a separate job: this skill starts once the summary range exists or is being designed. The deliverable is the file or a numbered step list, checked by changing the data and looking at the result.
Mental model
- A dashboard has three layers: source data, a summary range, and the charts. Keep them on three sheets, Data, Calc and View. The FAST Standard separates worksheets by type in the same way: foundation sheets with the inputs, workings, and presentation. Charts read Calc; nobody types numbers on View.
- Source data is one list: labels in the first row, the same kind of item in each column, no blank rows or columns inside it (Microsoft, data organization guidelines), and no merged cells (UK Analysis Function). Leave at least one blank row and one blank column between it and other data (same page).
- A chart draws a range. If the range does not move with the data, the chart goes stale without any error.
Rules
Match the feature to the app
| Feature | Excel (Microsoft 365, 2024, 2021) | Google Sheets |
|---|---|---|
| Summary that follows the data | Dynamic array formulas spill into the cells below; they are not supported inside an Excel table, so put them in the plain grid | QUERY (select, where, group by, pivot, label) and FILTER, which returns #N/A when nothing matches |
| Pivot summary | PivotTable, then PivotChart | Pivot table; filter with a Filters field in the editor |
| Filter control | Slicer; Timeline for a date field | Slicer (Data, Add a slicer) |
| Cell-sized chart | Sparklines: line, column, win/loss | SPARKLINE function: line (default), bar, column, winloss |
| In-cell bars | Conditional formatting, Data Bars | SPARKLINE with charttype bar |
Older Excel shows dynamic array formulas as legacy array formulas that do not resize. Run the Compatibility Checker before sharing a workbook with people on older versions. Excel slicers for tables and data model PivotTables need Excel for Windows or Mac; Excel for the web creates only local PivotTable slicers. Timelines need a date field in a PivotTable.
Pick the chart from the reader's task
| Reader's task | Excel and Sheets name | Condition |
|---|---|---|
| Compare categories | Column; Bar when labels are long | Clustered, not stacked, unless totals matter |
| Trend over time | Line | Not a stacked line: it sums the data, which can mislead |
| Share of one whole | Pie | One series, no negative values, at most seven categories (Microsoft) |
| Two numeric measures | Scatter (XY) | Uneven spacing or many points |
| Series with different forms | Combo | Columns for amounts, line for a rate |
| Change over time and total | Area | Non-stacked areas can hide a series; use lines instead |
Recommended Charts (Insert, Recommended Charts) proposes a chart for the selected cells, and Alt+F1 inserts one at once. General chart form and colour decisions follow the data-visualization guidance; this skill covers the app.
Remove default clutter
In Excel use Chart Design, Add Chart Element to switch off or move the title, axis titles, legend, gridlines and data labels. In Sheets use the Customize tab. To hide gridlines but keep axis labels in Sheets, give the gridlines the chart background colour. Delete the legend for a single series, and put the message in the title.
Make ranges grow with the data
- Excel: a chart pointed at a fixed range ignores new rows. Define names that resize, for example =OFFSET($B$2,0,0,COUNTA($B:$B)-1), and enter the names as the series values and category labels with the sheet name, for example =Sheet1!Sales. Microsoft's page gives the full steps. COUNTA counts formulas and stray entries in the column, so keep the column clean.
- Sheets: a pivot table is drawn from its Select data range; after rows are added outside that range, change the range in the pivot table editor. For the chart, open Setup, Data range and extend the range. QUERY and FILTER output feeds a chart range that has room to grow.
- Every case ends with a test: append one row of dummy data, confirm the chart took it, then delete the row.
Slicers, timelines, sparklines, data bars
- Excel: a slicer connects only to PivotTables that share its data source; use Report Connections or Slicer Settings to attach more.
- Excel: a timeline filters on a date field and switches between years, quarters, months and days. To use a slicer and a timeline on the same date field, turn on Allow multiple filters per field in PivotTable Options.
- Sparklines have a custom axis minimum and maximum; by default Excel determines the scale. Set the same custom values on rows that are compared. Choose how empty cells show: gaps, zero or connected, and whether hidden rows count.
- Sheets: a slicer filters the charts and pivot tables on its sheet that use the same data set, not formulas.
- Data bars take their scale from Lowest/Highest Value, Number, Percent, Percentile or Formula. Percentile limits the influence of extreme values, so use it when one outlier would flatten the rest.
Generate a workbook from Python
| XlsxWriter | openpyxl | |
|---|---|---|
| Writes new files | Yes | Yes |
| Reads or modifies existing files | No | Yes |
| Charts | line, column, bar, pie, doughnut, area, radar, scatter, stock; no 3D | Includes bubble and surface |
| Sparklines | Yes (Excel 2010 or later) | Dropped when a workbook is loaded, so saving an edited file loses them |
For a new workbook with charts, use XlsxWriter. Use openpyxl only to edit an existing file, and reopen the result to check that charts survived. Write the source as a table with add_table, build the summary on Calc, and point each series at a Calc range. Run it with uv run --with xlsxwriter python script.py:
import xlsxwriter
rows = [
["Jan", "East", 10], ["Jan", "West", 8],
["Feb", "East", 12], ["Feb", "West", 9],
["Mar", "East", 15], ["Mar", "West", 11],
]
wb = xlsxwriter.Workbook("out.xlsx")
data = wb.add_worksheet("Data")
calc = wb.add_worksheet("Calc")
view = wb.add_worksheet("View")
data.add_table("A1:C7", {"name": "Sales", "data": rows, "columns": [{"header": "Month"}, {"header": "Region"}, {"header": "Revenue"}]})
calc.write_row("A1", ["Month", "East", "West"])
for i, month in enumerate(["Jan", "Feb", "Mar"], start=2):
calc.write(f"A{i}", month)
for col in "BC":
calc.write_formula(f"{col}{i}", f"=SUMIFS(Sales[Revenue],Sales[Month],$A{i},Sales[Region],{col}$1)")
chart = wb.add_chart({"type": "line"})
chart.add_series({"name": "=Calc!$B$1", "categories": "=Calc!$A$2:$A$4", "values": "=Calc!$B$2:$B$4"})
view.insert_chart("A1", chart)
view.add_sparkline("H2", {"range": "Calc!B2:B4"})
wb.close()Check the file by reloading it with uv run --with openpyxl python -c "import openpyxl; wb=openpyxl.load_workbook('out.xlsx'); print(wb.sheetnames, len(wb['View']._charts))". openpyxl drops sparklines when it loads a workbook, so a reload cannot confirm them: open the file in the spreadsheet app, or find the sparkline group in the worksheet XML inside the xlsx (unzip -p out.xlsx xl/worksheets/sheet3.xml | grep -c sparklineGroup). Formula cells hold no computed values until Excel opens the file, so read the numbers in the app, or pass the value argument to write_formula.
When the user cannot be asked, assume Microsoft 365 or current Google Sheets and say so.
Examples
Fixed range to growing range. Bad: a line chart on A1:B13; the January row added later never appears. Good: names defined with OFFSET and COUNTA drive the series, and a dummy row proved the chart extends.
Chart on raw rows to chart on a summary. Bad: a column chart on 3,000 transaction rows. Good: a Calc sheet with one row per month and one column per region, and the chart reads that range.
Ten charts to one column. Bad: ten tiny line charts, one per product. Good: one sparkline per row beside the table, sharing one axis maximum so the rows compare.
Output format
- Workbook path or sheet link, and the sheets with their roles.
- Each chart with the range it reads and the question it answers.
- The app and version assumed, and the one test done (the dummy row).
Checklist
- App and version are stated; no feature outside that version is used.
- Data, Calc and View are separate; the source is one list with no merged cells.
- Each chart name matches the reader's task; pies have one series and at most seven categories.
- Title, legend, gridlines and labels were set on purpose.
- A dummy row was added; the chart, pivot and sparklines took it; the row was removed.
- Slicers and timelines are connected to every PivotTable they must filter.
- A generated file was reopened; its sheets, charts and sparklines exist, and numbers were read in the app.
Composition / References
Scope limits: formulas, lookups, cleaning and pivot table building are a separate job; statistics, general chart form and colour, and charts for web applications are others.
- Microsoft Support, "Guidelines for organizing and formatting data on a worksheet": https://support.microsoft.com/en-us/office/guidelines-for-organizing-and-formatting-data-on-a-worksheet-90895cad-6c85-4e02-90d3-8798660166e3
- Microsoft Support, "Available chart types in Office": https://support.microsoft.com/en-us/office/available-chart-types-in-office-a6187218-807e-4103-9e0a-27cdb19afb90 ; "Create a chart from start to finish": https://support.microsoft.com/en-us/office/create-a-chart-from-start-to-finish-0baf399e-dd61-4e18-8a73-b3fd5d5680c2
- Microsoft Support, slicers: https://support.microsoft.com/en-us/office/use-slicers-to-filter-data-249f966b-a9d5-4b0f-b31a-12651785d29d ; timelines: https://support.microsoft.com/en-us/office/create-a-pivottable-timeline-to-filter-dates-d3956083-01be-408c-906d-6fc99d9fadfa ; sparklines: https://support.microsoft.com/en-us/excel/analyze-trends-in-data-using-sparklines ; conditional formatting: https://support.microsoft.com/en-us/excel/use-conditional-formatting-to-highlight-information-in-excel
- Microsoft Support, dynamic arrays: https://support.microsoft.com/en-us/excel/dynamic-array-formulas-and-spilled-array-behavior ; in older Excel: https://support.microsoft.com/en-us/office/dynamic-array-formulas-in-non-dynamic-aware-excel-696e164e-306b-4282-ae9d-aa88f5502fa2
- Microsoft Learn, "Use defined names to automatically update a chart range": https://learn.microsoft.com/en-us/troubleshoot/microsoft-365-apps/excel/defined-names-to-update-chart-range
- Google Docs Editors Help: charts https://support.google.com/docs/answer/63824 , chart types https://support.google.com/docs/answer/190718 , SPARKLINE https://support.google.com/docs/answer/3093289 , QUERY https://support.google.com/docs/answer/3093343 , FILTER https://support.google.com/docs/answer/3093197 , pivot tables https://support.google.com/docs/answer/1272900 , slicers https://support.google.com/docs/answer/9245556
- XlsxWriter documentation: https://xlsxwriter.readthedocs.io/working_with_charts.html , https://xlsxwriter.readthedocs.io/working_with_sparklines.html , https://xlsxwriter.readthedocs.io/working_with_formulas.html ; openpyxl charts: https://openpyxl.readthedocs.io/en/stable/charts/introduction.html
- UK Government Analysis Function, "Releasing statistics in spreadsheets": https://analysisfunction.civilservice.gov.uk/policy-store/releasing-statistics-in-spreadsheets/
- FAST Standard, version 02c, 2019: https://fast-standard.org/wp-content/uploads/2019/10/FAST-Standard-02c-July-2019.pdf