Search code examples
csvhighchartslineyaxis

Highcharts Y-axis per series csv


I'm working on highcharts to view my data. And I would like to do a single chart with 2 lines inside, with one lines as 1 y-axis.

I already implement the chart like this:

$.get("http://1001dev.com/Chahine/wp-content/themes/consulting-child/data/fonds/DigitalStarsEurope/assetsFR.csv", function(csv) {
        $('#EuropeActifs').highcharts({
            
             yAxis: [{ // Primary yAxis
                    labels: {
                        format: '{value} M',
                       
                    },
                    title: {
                        text: 'Actifs en € ',
                        
                    },
                    opposite: true

                }, { // Secondary yAxis
                    gridLineWidth: 0,
                    labels: {
                        format: '{value}',
                       
                    },
                    title: {
                        text: 'Nombre de parts',  
                    }
                }],
            
            data: {
                csv: csv
            }
        });
    });

This is my CSV:

 Date,Actifs en €,Nombre de parts
 13/11/1998,461728.00,30286.50
 11/12/1998,460454.00,30286.50
 08/01/1999,499715.00,30286.50
 05/02/1999,502512.00,30933.50
 05/03/1999,502481.00,30933.50
 02/04/1999,505413.00,31105.00
 30/04/1999,519929.00,31105.00
 28/05/1999,516903.00,31105.00

Obviously my CSV is longer than this. But you can see the idea I think.

I would like to have the data for Actifs en € associete to the y-axis Primary and the data for Nombre de parts associate to the y-axis Secondary

How can I do that?

Thanks a lot for your help


Solution

  • You need to specify which yAxis you want the different series to be in, like this:

    series: [{
        yAxis: 1
    }, {
        yAxis: 0
    }]
    

    Working example based on your data: https://jsfiddle.net/ewolden/q489nsgw/2/

    API on data: http://api.highcharts.com/highcharts/data

    API on series.yAxis: http://api.highcharts.com/highcharts/series.line.yAxis