0

I'm using Highcharts plugins "dragable points" and "export-csv".

I'm using these to place circles on a chart with a background drawing. This is so I can use these points to change colour as the data for that point updates.

My problem is I'm trying to export the "Name" of the point in the csv file and I'm only able to get the x and y values.

Data I'm loading in looks like this

{name: 'd1', color: '#FF0000', x: 10, y: 100},{name: 'd2', color: '#FF0000', x: 30, y: 100}

This places the points in a set location and then I'm using the dragable plugin to move the points to the new locations. Once there I would like the export-csv plugin to output the "name:" along with the "x: and y:" values.

Question: Is there a way to set the export-csv plugin to include the name of the point?

Rob Wright
  • 63
  • 1
  • 1
  • 8

2 Answers2

3

Don't even bother with the plugin. You can code very simply in like 8 lines of JavaScript:

$('#getcsv').click(function () {
    var csv = "Series;Name;X;Y\n";
    $.each(Highcharts.charts[0].series, function(i,s){
        $.each(s.points, function(j,p){
            csv += s.name + ";" + p.name + ";" + p.x + ";" + p.y + "\n";
        });
    });
    alert(csv);
});

Here's an example.

Mark
  • 106,305
  • 20
  • 172
  • 230
  • Excellent Mark, thank you for your support on this. I can see in your example that using your javascript works. When I've added this code to my script along with the button I don't get the pop-up window! Also, how could I get this data output - sorry if thats a daft question. Thanks – Rob Wright Nov 10 '14 at 20:30
  • Okay, I've sorted out why alert wasn't working - I think I had poistioned your code above, outside of the last }); in my script! – Rob Wright Nov 10 '14 at 23:46
  • Still would like to push the results out to a csv file - any clues :o) Thanks – Rob Wright Nov 10 '14 at 23:48
0

If you check out the docs and the source code for this plugin you can see that it is just explicitly getting the data as a two dimensional array of x and y points (date or category and the yValue). To get it to return the other items you would need to extend this plugin (or roll your own).

wergeld
  • 14,332
  • 8
  • 51
  • 81
  • Yes thats what I was afraid of - probably taking it beyond my skill level! Good to get another opinion as I looked through and couldn't see an option for this. Thanks Rob – Rob Wright Nov 10 '14 at 16:50