How to get all json values in line chart

前端 未结 3 745
谎友^
谎友^ 2021-01-28 09:59

I have many Json values, using them I am going to create a line chart but it shows only one value in the chart. I am a newbie to javascript and have an idea to plot all values

3条回答
  •  温柔的废话
    2021-01-28 10:06

    jsFiddle

      Update Code: 
    
    
    
    
    dataRevenue=
           [
            { x: new Date(2014, 00,30), y: 0 },
            { x: new Date(2014, 01,31), y: 7},
            { x: new Date(2014, 02,28), y: 47}
    
            ];
    
    dataTip =[
            { x: new Date(2014, 00,30), y: 0 },
            { x: new Date(2014, 01,31), y: 3},
            { x: new Date(2014, 02,28), y: 8}
    
            ]; 
    
        var chart = new CanvasJS.Chart("chartContainer",
        {
          theme: "theme2",
          title:{
            text: "line chart"
          },
          axisX: {
            valueFormatString: "MMM",
            interval:1,
            intervalType: "month"
    
          },
          axisY:{
            includeZero: false
    
          },
          data: [
          {        
            type: "line",
            //lineThickness: 3,        
            dataPoints: dataTip
          },
           {        
            type: "line",
            //lineThickness: 3,        
            dataPoints: dataRevenue
          }
    
    
    
          ]
        });
    
    chart.render();
    

提交回复
热议问题