cascada
Posts: 2
Joined: Tue Nov 20, 2018 9:13 am

Start data point from left

Hi,

We're using Highcharts to display electricity prices.
Problem is, when we only have one data point on chart, it is aligned in the middle.
Is it possible to make it start from left, not in the middle?

Image

Is there an option to make it start from left?

Code: Select all

$(function () {
    $('#container').highcharts({
        chart: {
        },
        xAxis: {
            categories: ['Jan']
        },
        
        plotOptions: {
            series: {
                dataLabels: {
                    align: 'left',
                    enabled: true,
                    rotation: 270,
                    x: 2,
                    y: -10
                }
            }
        },
        
        series: [{
            data: [29]
        }]
    });
});
http://jsfiddle.net/VWYMW/35/

Thank you!
bastss
Site Admin
Posts: 1208
Joined: Wed Oct 17, 2018 10:59 am

Re: Start data point from left

Hello cascada,

Yes, it is possible to start from left, but it's not included in regular API and we need to write proper function on load event. API: https://api.highcharts.com/highcharts/chart.events.load Check this example: https://jsfiddle.net/Bastss/n7xvLgk6/

Best regards!
Sebastian Wędzel,
Highcharts Developer
cascada
Posts: 2
Joined: Tue Nov 20, 2018 9:13 am

Re: Start data point from left

Thank you, I tried it, it works on test case but in live environment it moves everything to the right instead:

When there is only one point (00:00):
https://dashboard-test.elering.ee/en/np ... period=day

And when there is full data for every hour 00:00 - 23:00
https://dashboard-test.elering.ee/en/np ... period=day

It also changes xAxis labels to years.
It should be like that:
https://dashboard.elering.ee/en/nps/pri ... period=day

Or when there is only one data, it's for 00:00:
https://dashboard.elering.ee/en/nps/pri ... period=day
bastss
Site Admin
Posts: 1208
Joined: Wed Oct 17, 2018 10:59 am

Re: Start data point from left

Cascada,

Could you send a demo to work on it? It will be much easier if a demo will include description what you want to change or achieve. Because for now, everything looks fine for me except the first link where the chart is blind.

Best regards!
Sebastian Wędzel,
Highcharts Developer

Return to “Highcharts Usage”