create Chartist line graph by taking values from json files

480 views Asked by At

I am tring to create a line graph by taking values from json file for x-axis and y-axis, but i am not able to fill the labels and series, can anyone please provide any inputs.

sample code :

<chartist class="ct-chart ct-major-twelfth" chartist-chart-type="Line" 
            chartist-data="View.lineData" chartist-chart-options="View.lineOptions">
</chartist>

ctrl.lineData = {
        labels: [],
        series: []
};

function data(data, cb) {
  cb({
      labels: getLabels(),
      series: getSeries()
    });

function getLabels() {
  return [
          ctrl.result[0] // i have to get the date values from json (1997,1999)
         ];
}

function getSeries() {
  return [
          ctrl.result[0] // have to fetch count values from json
         ];
}

sample json:

[ results :
          count: 6
{
    "year": 1997,
    "make": "Ford",
    "model": "E350",
    "description": "ac, abs, moon",
    "price": 3000
},
{
    "year": 1999,
    "make": "Chevy",
    "model": "Venture \"Extended Edition\"",
    "description": "",
    "price": 4900
}
]
0

There are 0 answers