Home Forums Chart Support Date on axis from C# MVC

Date on axis from C# MVC

Viewing 3 posts - 1 through 3 (of 3 total)
  • #42070

    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?

    • This topic was modified 1 year, 9 months ago by dpanscik.
    #42072

    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?

    #42088

    @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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.