I am looking into using your package for some simple line plotting on a web site. So, I tried a simple AJAX call that returns some data to be plotted.
Everything works with simple integer date points for both X and Y. However, when I change the X axis data type to Date, the data points did not show. I am using C# and their JSON helper.
List <dataPoint> array= new List<dataPoint> () ;
DateTime t = DateTime.Now;
array.Add(new dataPoint(t,10));
t= new DateTime(2013,6,1);
array.Add(new dataPoint(t,30));
Json.Write(array, Response.Output);
this is the JSON string returned by AJAX:
[{“x”:”\/Date(1370439429173)\/”,”y”:10},{“x”:”\/Date(1370070000000)\/”,”y”:30}]
and here is the java script function:
$.ajax({
dataType: “json”,
url: “getChartData.cshtml”,
success: function (data1, status) {
alert(“hello” + data1);
var chart = new CanvasJS.Chart(“chartContainer”, {
data: [{ type: “line”,
dataPoints: data1
}]
});
chart.render();
}
});
As I mentioned, it works when the array returned is a list of <int,int>. The problem occurs when the lsit returned is <DateTime, int>
Thanks for you help. This looks like a nice package.
Charles