Cant bind line Flot Chart

124 views Asked by At

I am not able to bind my flot line chart. Below is my sample data with date coloumn also. What should be the formatof date format. Also do we need to set anymore options like x axis and y axis in $.plot :

    [
  {
    "label": "\/Date(1433529000000+0530)\/",
    "data": 200.00
  },
  {
    "label": "\/Date(1436121000000+0530)\/",
    "data": 150.00
  },
  {
    "label": "\/Date(1438799400000+0530)\/",
    "data": 1500.00
  },
  {
    "label": "\/Date(1441477800000+0530)\/",
    "data": 10000.00
  },
  {
    "label": "\/Date(1444069800000+0530)\/",
    "data": 500.00
  },
  {
    "label": "\/Date(1446748200000+0530)\/",
    "data": 5000.00
  },
  {
    "label": "\/Date(1449340200000+0530)\/",
    "data": 150.00
  }
]
1

There are 1 answers

0
Raidri On

The default flot data format is an array of arrays, not objects. Change your data to the below format. And you don't need any options, flot will use default options if you don't specify them. But since you use time values for your x-axis you should use mode: time in your options. Together this leads to something like this:

var data = [
    [1433529000000, 200.00],
    [1436121000000, 150.00],
    [1438799400000, 1500.00],
    [1441477800000, 10000.00],
    [1444069800000, 500.00],
    [1446748200000, 5000.00],
    [1449340200000, 150.00]
];
var options = {
    series: {
        mode: 'time'
    }
};
$.plot('#placeholder', [data], options);