Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can extend several lines horizontally along the x-axis in Highcharts by using the following steps:

  1. First, define your chart options and add the necessary series data.

  2. Next, set the x and y values for each point in your series. For the y values, you can use an array to draw multiple lines.

  3. Then, set the lineWidth option for your series to the desired width.

  4. To extend the lines along the x-axis, you can set the pointStart and pointInterval options for the x-axis. The pointStart option sets the starting value for the first point in the series, and the pointInterval option sets the distance between each point along the x-axis.

  5. Finally, adjust any other chart options as needed, such as the chart title, legend, and axis labels.

Here's an example code snippet to illustrate how to extend multiple lines horizontally in Highcharts:

Highcharts.chart('container', {
    title: {
        text: 'Multiple Lines on X-Axis'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May']
        //Use pointStart and pointInterval options to extend lines horizontally
        pointStart: 0,
        pointInterval: 1,
    },
    yAxis: {
        title: {
            text: 'Values'
        }
    },
    legend: {
        layout: 'vertical',
        align: 'right',
        verticalAlign: 'middle'
    },
    series: [{
        name: 'Line 1',
        data: [5, 10, 15, 20, 25]
    }, {
        name: 'Line 2',
        //Draw multiple lines by using an array for y-values
        data: [[2, 8, 10, 16, 20]]
    }, {
        name: 'Line 3',
        data: [7, 14, 21, 28, 35]
    }],
    //Set the line width for each series
    plotOptions: {
        line: {
            lineWidth: 2
        }
    }
});

In this example, we have three series, each with different y-values but using the same x-axis categories. We set the pointStart option to 0 and the pointInterval option to 1 to extend the lines horizontally along the x-axis. We also set the lineWidth option to 2 for each series to make the lines thicker.