You must be logged in to post your query.
Home › Forums › Chart Support › Date on axis from C# MVC
I am just getting warmed up to canvasJS so forgive me if I am clunky in asking my question.
I am trying to use this javascript example;
var dps = [ { x: new Date(2012,00,01), y: [new Date(2016, 1, 15, 8, 16, 15), new Date(2016, 1, 15, 9, 16, 15)] }, // y: [Low ,High] { x: new Date(2012,00,01), y: [new Date(2016, 1, 15, 11, 20, 15), new Date(2016, 1, 15, 13, 20, 15)] }, { x: new Date(2012,02,01), y: [new Date(2016, 1, 15, 5, 16, 15), new Date(2016, 1, 15, 8, 30, 15)] }, { x: new Date(2012,03,01), y: [new Date(2016, 1, 15, 4, 12, 15), new Date(2016, 1, 15, 12, 1, 15)] }, { x: new Date(2012,04,01), y: [new Date(2016, 1, 15, 8, 16, 15), new Date(2016, 1, 15, 9, 00, 15)] }, { x: new Date(2012,05,01), y: [new Date(2016, 1, 15, 7, 16, 15), new Date(2016, 1, 15, 10, 18, 15)] }, ];
formatted for c# MVC CONTROLLER;
dataPoints.Add(new DataPoint(new DateTime(2012,00,01), new DateTime(2016, 1, 15, 8, 16, 15), new DateTime(2016, 1, 15, 9, 16, 15))); dataPoints.Add(new DataPoint(new DateTime(2012,00,02), new DateTime(2016, 1, 15, 11, 20, 15), new DateTime(2016, 1, 15, 13, 20, 15)); dataPoints.Add(new DataPoint(new DateTime(2012,00,03), new DateTime(2016, 1, 15, 5, 16, 15), new DateTime(2016, 1, 15, 8, 30, 15));
But the MVC version does not draw anything on the table. So I think my formatting is wrong.
Any ideas of the correct C# formatting?
@dpanscik,
The datapoint y-value can only accept numeric values as of now. Passing the dataPoints with numerical values as shown in the code-snippet below should work fine in your case,
dataPoints.Add(new DataPoint(new DateTime(2016, 01, 01), new double[] { 656.289978, 657.719971, 547.179993, 587.000000 }));
Kindly refer to our gallery page for an example with complete code.
— Adithya Menon Team CanvasJS
You must be logged in to reply to this topic. Login/Register