Mattia Carolo
Mattia Carolo

Reputation: 153

Create a heatmap using highcharts through csv

I need to upload a csv made like this

rsid             Complex                 score
rs531730856  ARNTL.SwissRegulon   -0.1658514285714286
rs531730856  BHLHE40.SwissRegulon  0.033113124999999966
rs531730856  BMAL1_HUMAN.H10MO.C  -0.16585214285714286
rs531730856  CUX1_HUMAN.H10MO.C    0.10511399999999993
rs531730856        DR-1            0.33170428571428573

Problem is that highcharts returns me error 14 which, if I understood correctly, it's because the Complex field it's not a number. Is there a way where i can import directly a csv made like this?

Upvotes: 0

Views: 107

Answers (1)

Mark Z.
Mark Z.

Reputation: 2447

Unfortunately not, you'll have to do an intermediate step to process that CSV if you wish to import it directly via the csv data/url functionality built into highcharts. See: https://www.highcharts.com/docs/working-with-data/data-module

CSV can be loaded in two ways. Either data.csv, that holds a CSV string to be read into the chart, or, since v6.1, data.csvURL that points to a file location. By default, the first row of the CSV data is interpreted as series names, the first column signifies category names or X values/dates, and subsequent columns hold data values.

Sample CSV contents:

Categories,Apples,Pears,Oranges,Bananas
John,8,4,6,5
Jane,3,4,2,3
Joe,86,76,79,77
Janet,3,16,13,15

Sample chart initialization:

Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
    data: {
        // enablePolling: true,
        csvURL: window.location.origin + '/studies/data.csv'
    },
    title: {
        text: 'Fruit Consumption'
    },
    yAxis: {
        title: {
            text: 'Units'
        }
    }
});

Upvotes: 1

Related Questions