A Readable Hourly Weather Chart: Chart.js, 4 Series, 7 Days
An icon says "rain today." A chart says "rain 2–4pm, then wind picks up." How to fit 4 series and 168 hours into one readable Chart.js graph.

Why a chart beats an icon for planning
While a sun-and-cloud icon in a weather forecast looks nice, it tells you almost nothing for detailed planning. It only tells you that there will be occasional showers today. A chart, on the other hand, shows you that it will rain from 2:00 PM to 4:00 PM, followed by a sharp drop in temperature and a rising north wind. This is the fundamental difference between just grabbing a jacket and rescheduling outdoor work to the morning.
However, displaying a large amount of meteorological data clearly is a challenge for developers. How do you render four different variables hour by hour over up to seven days in a single chart that remains readable even on a mobile screen? The solution is a combination of the Angular framework, the Chart.js library, and several custom extensions that allow users to interactively filter out noise and focus on what matters.
When I was designing the client side used by the entire Weather InTouch project, it became clear that standard chart rendering options were not enough. I had to build a component that is fast, fully reactive, and does not cause unnecessary DOM re-renders. Modern Angular with support for zoneless mode and signals proved to be the ideal choice for this purpose.
Four series in one chart without visual chaos
When building a complex weather chart, I found Angular plus the Chart.js library ideal for defining a clean data layer and visualizing it. To provide the user with a comprehensive overview, we need to display four key variables in a single time frame:
- Air temperature (solid line)
- Dew point (dashed line indicating humidity)
- Precipitation (bar chart in the background)
- Wind speed (line with a distinct style and its own axis)
To avoid visual chaos, the chart uses three independent vertical axes (Y-axes). Temperature and dew point share the left axis, expressed in degrees. Precipitation has the right axis marked in millimeters, and wind has its own hidden or secondary axis so that its curve does not interfere with temperature extremes.
Units have to be localized. Users in different parts of the world require different formats (°C versus °F, millimeters versus inches, meters per second versus kilometers per hour or knots). In Angular these preferences live in reactive signals (Signal); changing the units or theme triggers an effect that rebuilds the Chart.js configuration with recalculated values.
The chart component itself is designed as a stateless standalone component. Data flows into it exclusively through inputs (@Input). The component does not fetch its own data, which makes it easier to test and reuse; the only outbound request happens when a signed-in user toggles a series and the preference is saved.
import { Component, input, computed, effect, ElementRef, viewChild } from '@angular/core';
import { Chart, ChartConfiguration } from 'chart.js/auto';
@Component({
selector: 'app-weather-chart',
standalone: true,
template: `<canvas #chartCanvas></canvas>`,
styleUrls: ['./weather-chart.component.css']
})
export class WeatherChartComponent {
readonly weatherData = input.required<WeatherData[]>();
readonly units = input.required<UserUnits>();
private canvas = viewChild.required<ElementRef<HTMLCanvasElement>>('chartCanvas');
private chartInstance?: Chart;
private chartConfig = computed<ChartConfiguration>(() => {
const data = this.weatherData();
const currentUnits = this.units();
return {
type: 'line',
data: {
labels: data.map(d => d.timestamp),
datasets: [
{
label: 'Temperature',
data: data.map(d => convertTemp(d.temp, currentUnits.temp)),
yAxisID: 'yTemp',
borderColor: '#ff5722',
tension: 0.4
},
{
label: 'Precipitation',
type: 'bar',
data: data.map(d => convertPrecip(d.precip, currentUnits.precip)),
yAxisID: 'yPrecip',
backgroundColor: 'rgba(33, 150, 243, 0.3)'
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
yTemp: { type: 'linear', position: 'left' },
yPrecip: { type: 'linear', position: 'right', grid: { drawOnChartArea: false } }
}
}
};
});
constructor() {
effect(() => {
const config = this.chartConfig();
this.updateChart(config);
});
}
private updateChart(config: ChartConfiguration) {
if (this.chartInstance) {
this.chartInstance.destroy();
}
const ctx = this.canvas().nativeElement.getContext('2d');
if (ctx) {
this.chartInstance = new Chart(ctx, config);
}
}
}
Custom plugin for day separators
When displaying a long time span, such as 168 hours (7 days), the horizontal X-axis becomes extremely cluttered. While standard Chart.js labels can intelligently hide duplicate hour labels, the user quickly loses track of where Tuesday ends and Wednesday begins.
To solve this problem, you need to implement a custom plugin in Chart.js that draws vertical separator lines in the background of the chart exactly where a new day starts (i.e., at midnight).
The plugin is registered directly in the chart configuration and uses the beforeDraw or afterDraw method to access the 2D canvas. Using internal Chart.js methods to convert data points to pixels, we can precisely locate the indexes corresponding to midnight and draw a subtle vertical line with the day label near the top edge of the chart.
const daySeparatorPlugin = {
id: 'daySeparator',
afterDraw: (chart: Chart) => {
const { ctx, chartArea: { top, bottom }, scales: { x } } = chart;
const ticks = x.ticks;
ctx.save();
ctx.strokeStyle = 'rgba(255, 255, 255, 0.15)';
ctx.lineWidth = 1;
ctx.fillStyle = 'rgba(255, 255, 255, 0.6)';
ctx.font = '11px sans-serif';
ticks.forEach((tick, index) => {
const date = new Date(chart.data.labels[index] as string);
if (date.getHours() === 0) {
const xPos = x.getPixelForValue(index);
// Draw vertical line
ctx.beginPath();
ctx.moveTo(xPos, top);
ctx.lineTo(xPos, bottom);
ctx.stroke();
// Draw day name
const dayName = date.toLocaleDateString('cs-CZ', { weekday: 'short' });
ctx.fillText(dayName, xPos + 5, top + 15);
}
});
ctx.restore();
}
};
Moving “now” line
A user looking at the chart usually needs to orient themselves relative to the current moment. What is happening right now, and what lies ahead in the coming hours? A moving vertical line labeled “now” serves this purpose.
This line must move dynamically as time passes. In an application running on Angular 22 without zone-based change detection (zoneless), we can optimize this process so that it does not strain the CPU with constant re-rendering. It updates about once a minute.
The chart also watches tab activity through the Page Visibility API. If the user switches to another tab and returns after an hour, the visibility state change lets the chart repaint the current line straight away instead of waiting for the next tick of the once-a-minute timer.
This approach ensures that the current time information in the chart is always accurate while saving battery life on mobile devices, where users check weather forecasts most often.
Tooltips that make sense
Default tooltips in Chart.js are rendered directly onto the canvas. That limits styling, responsiveness, and accessibility. If we want to display four different variables with their specific units and icons, the standard text box quickly reaches its limits.
A custom HTML tooltip solves this problem. Chart.js allows you to completely disable the native tooltip and instead provide an external callback function, which passes coordinates and raw data when the cursor hovers over a chart point.
Our Angular component captures these coordinates and positions an absolutely positioned HTML element over the canvas. The benefits are obvious:
- Ability to use standard CSS (Grid, Flexbox) for perfect alignment.
- Display of color indicators, units, and additional text in a readable format.
- Smooth CSS transitions when moving the cursor between individual hours.
- Easier support for touch devices, where the tooltip behaves as a floating card below the chart.
Ranges from 24 to 168 hours
Every situation requires a different level of detail. If you are planning an afternoon bike trip, you want a detailed breakdown of the next 24 or 48 hours. If you are planning a weekend or a work week, you need to see a 7-day outlook (168 hours).
The chart supports switching between these ranges; the two longest (72 and 168 hours) are part of the paid tier, so a free viewer’s data stops earlier. Because the weather cards are completely stateless, changing the range just filters the data array passed to the component. The component receives the whole array of hours and slices the chosen window itself; the parent only holds the selected range.
To read about how to retrieve such data without overloading the server or the provider, check out the article on how data gets into the chart on a budget.
Thanks to signal-based reactivity, Angular immediately registers changes to the input array, recalculates the Chart.js configuration, and the chart redraws the curves. Toggling a series in the legend keeps the Chart instance alive — only the dataset’s visibility changes; a range, unit or theme change rebuilds it.
What the user enables, stays enabled
When displaying four variables at once, the chart might feel too cluttered for some users. Someone might only care about temperature and precipitation, with no interest in wind or dew point. By default, Chart.js allows users to hide individual series by clicking on the legend.
In a typical web application, however, this setting is lost upon page refresh. Within the Weather InTouch platform, the chart persists which series are visible.
If a user hides the wind series, this preference is immediately saved to the browser’s localStorage. If the user is logged into their account, this setting is synchronized to the database via an API (built on a NestJS + MongoDB + Redis architecture).
When the user logs in from any other device (such as a mobile phone), the chart automatically renders in the configuration the user selected. The result is a personalized interface that respects what each user wants and avoids annoying them with repeated filter setups on every visit.
You can find more detailed information about the overall architecture and other features of this meteorological platform on the page describing the entire Weather InTouch project.

