Highlighting Graph Area

TODO: collapasable, copyable, download, etc

Using highcharts, how would I draw a rectangle over a region of the graph to highlight an area? I have a start and end time To draw a rectangle over a region of a Highcharts graph to highlight an area between a start and end time, you can use the plotBands feature on the xAxis or yAxis, depending on the orientation of your data. Here's a general guide on how to do this:

  1. Identify the Axis: Determine whether the start and end times are represented on the x-axis or the y-axis of your chart.

  2. Add Plot Bands: Use the plotBands property within the axis configuration to add a band that spans from the start time to the end time.

Here's a basic example assuming your start and end times are on the x-axis:

Highcharts.chart('container', {
    // Other chart configurations ...

    xAxis: {
        // ... other xAxis configurations ...

        plotBands: [{
            color: 'rgba(68, 170, 213, 0.2)', // Color of the rectangle
            from: startTime, // Start time
            to: endTime, // End time
            label: {
                text: 'Highlighted Area', // Optional label
                style: {
                    color: '#606060'
                }
            }
        }]
    },

    // ... other chart configurations ...
});

Replace startTime and endTime with your actual start and end time values. The color property can be adjusted to change the appearance of the highlighted area. The label is optional and can be used to add a text label to the highlighted area.

If the times are on the y-axis, you would place the plotBands configuration inside the yAxis configuration in a similar manner.

Remember that the format of startTime and endTime should match the format of the axis. For example, if your axis uses timestamps, these values should also be timestamps.

Highlighting Graph Area created at Tue Jan 20 1970 17:36:40 GMT+0000 (Coordinated Universal Time)

Related Chats

Aggregate Highcharts data in 5-min. 0.561

Luxon for Human-Friendly Durations 0.327

Smoothly Animate Value with Timestamp 0.318

Draw Rects & Ovals 0.298

Get shows in range 0.294

Build Mac App in Xcode 0.292

Scale Data to New Range 0.288

Line Graphs for Observability 0.274

Extract `key` and `value`. 0.268