Build a complete display calendar, preserve gaps, and label the clocks behind each point.
Time-series charts: distinguish missing days, zeros and provisional periods
A line implies continuity
A time-series chart maps measurements to ordered instants or calendar periods. Connecting two observed points across an unobserved day implies a path that was never measured. A recorded zero is different: it says the instrument or process observed the period and counted none. Store both the period key and an observation-status field before drawing the line. The observation calendar defines which periods were expected. Use a visible break, hollow mark, or separate missingness strip when a period has no measurement; do not silently replace it with zero.
Name the two clocks
Operational data often has an event timestamp and a processing timestamp. A refund received late may belong to Tuesday's customer cohort but be visible only on Thursday's dashboard. Choose the clock that answers the chart's question and label it in the axis or subtitle. When bucketing timestamps into local days, choose one time zone and convert before taking the date. Daylight-saving changes make a local day shorter or longer than 24 hours in some regions. An elapsed-duration chart should use instants; a calendar-day chart should use dates in the declared zone.
Mark provisional periods
A current day is incomplete even when its count is known so far. Drawing it with the same line and scale as closed days invites a false decline. Carry a finalized flag from the data source, and either exclude the open interval or render it with a different stroke and an explicit as-of time. Late corrections can reopen an earlier point, so the chart's data-version label matters. A reader must know whether yesterday is final, not only whether the plotting job ran.
Protect the comparison
Never join lines across a product outage, a changed population, or a denominator change without an annotation or split. Keep the y-axis unit and calculation stable across the displayed range. If one week contains 42, 47 and 51 eligible cases while the next has a different intake rule, raw counts compare different populations. The aggregation contract should produce both numerator and denominator where a rate is intended. A moving average may reduce noise, but its window, edge behavior and missing-day policy must be stated.
Check the drawn output
Test an interior missing day, an observed zero, an incomplete final day, a late revision, and a daylight-saving boundary for the region being displayed. Confirm that hover text, downloadable data and the axis all use the same period key. A chart-library setting that connects nulls can undo a carefully prepared missingness contract. Inspect the rendered image, not only the input array. The text alternative should report the gap and the as-of timestamp too.
Worked contract
from datetime import date, timedelta
def complete_daily_series(observed: dict[date, int],
start: date, end: date) -> list[tuple[date, int | None]]:
if end < start or any(count < 0 for count in observed.values()):
raise ValueError("invalid date range or count")
if any(day < start or day > end for day in observed):
raise ValueError("observation outside display range")
return [(start + timedelta(days=offset),
observed.get(start + timedelta(days=offset)))
for offset in range((end - start).days + 1)]
points = complete_daily_series(
{date(2026, 8, 11): 47, date(2026, 8, 13): 0},
date(2026, 8, 11), date(2026, 8, 13))
assert [count for _, count in points] == [47, None, 0]Performance and operating cost
For D expected periods and O observed keys, validation plus calendar completion takes O(D + O) time and O(D) output space. The code assumes an already chosen calendar zone and one authoritative count per day. Converting event timestamps and resolving duplicates belong upstream. For a long history, query only the visible interval, and keep finalization state beside each point; creating a million empty periods in a browser is a serving error, not a charting technique.
Common Mistakes
- Converting an unobserved period into zero and drawing a continuous line.
- Bucketing by server time zone while labeling the axis with the user's local dates.
- Treating today's partial count as a completed daily value.
- Using a rolling average without showing its window and missing-period rule.
Validation drill
Plot a 29-day refund series with one observed zero, two missing days and a provisional last day. Export the period keys and states, then verify that the line breaks only where observation is absent.
Read next
- Aggregation grain and denominator: make every plotted mark auditable
- Axis scales, baselines and labels: prevent a correct number from telling a false story
- Dashboard filters and provenance: make every view reproducible
- Time-series calendar: distinguish missing periods from measured zeros
Continue this visualization path
- Chart annotations: align events to the right clock without claiming causality
- Forecast fan charts: label interval meaning and forecast horizon
- Calendar heatmaps: distinguish an empty day from an absent day
- Bump charts: show rank movement without losing ties or entrants
- P charts: account for varying denominators before flagging a rate
- Gantt timelines: make task dates and dependencies auditable
- Event-aligned charts: choose a baseline before comparing trajectories
- Survival curves: show who remains at risk after each event
- CUSUM charts: accumulate small departures from a stable target
- EWMA control charts: detect slow shifts against a frozen baseline
- Cohort retention heatmaps: keep immature cells blank
- Autocorrelation plots: align equal-spaced periods before reading lag peaks
- Historical percentile ribbons: show the spread of observations over time
- Seasonal subseries plots: compare the same cycle position across years
- Wind roses: map direction, speed and calm conditions without losing the denominator
- Connected scatterplots: preserve time order, gaps and trajectory direction
- Missingness matrices: reveal record-order patterns and co-missing fields
- Lag plots: pair exact periods before reading dependence
- Spectrograms: make time, frequency and color scales defensible
- Sparklines: keep small trends comparable and honest
