0

New to both Highcharts and WCF services. I can make either a series or data for highcharts but I can't seem to make multiple data arrays so my series has more that one line. Trying to make an array of arrays so my series has multiple data items in it. In jsFiddl I can get it to look like I want with the following code:

$(function() {
var chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container'
    },
    xAxis: {
        minPadding: 0.05,
        maxPadding: 0.05
    },

    series: [{
            name: 'Curve 1',
            data: [[150, 80], [155, 55], [159.5, 49.2],  [170, 45]]

        }, {
            name: 'Curve 2',
            data: [[160, 90], [165, 65], [170, 60],  [180, 55]]
        }]

});

});

My current WCF .svc file it serializing the JSON to look like {"data":[[150,80],[155,55],[160,50],[170,45]]}

I'd like to have one series "array" that has multiple data "arrays".

NOTE I have looked into DotNetHighcharts, but for now I don't want to use that because I will eventually need the onClick event for a point on the graph and it is my understanding that DonNetHighcharts does not support the event.

Open to any other ideas anyone has.

Thanks!

RichP
  • 525
  • 1
  • 10
  • 25

1 Answers1

0
public class Series
{
    public string name;
    public List<Data> data;
    public Series()
    {
        data = new List<Data>();
    }
}

public class Data
{ 
    public string name { get; set; }
    public double y { get; set; }
    public string color { get; set; }

}

and set serialize Object of seriesList to highcharts series:

series= new JavaScriptSerializer().Serialize(SeriesList));
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
  • Thanks that seems like a big step in the right direction. Having problems with the last line of code `series= new JavaScriptSerializer....` I can get output to my consuming page by putting this in my .svc `MemoryStream stream = new MemoryStream(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Series)); serializer.WriteObject(stream, mySeries); stream.Position = 0; StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); ` But I only get "data" Not "series" – RichP Nov 20 '12 at 14:45