backtrack
backtrack

Reputation: 8154

Angular chart is not working

I am using Angular-chart. Below is my JS

  $scope.Fchart = {
        series: "Employer",
        data: [ {x:"abc",y:450},{x:"bcd",y:500},{x:"cds",y:350} ]
    };

My HTML look like below

<div ac-chart="chartType" ac-data="Fchart" ac-config="config" id='chart' class='chart'></div>

Here is my App.js

var myApp = angular.module('myApp', ['ngRoute','ui.bootstrap','myApp.config','ui.select2','ngToast','angularCharts']);

When i run the application. I am getting undefined is not function in console. Also i am not getting the chart.

What went wrong ?

Can any one help me. Thanks,

Upvotes: 0

Views: 2273

Answers (1)

Kalhan.Toress
Kalhan.Toress

Reputation: 21901

series should be array : series: ['Employer'],

and y should be array {x:"abc",y:[450]}

$scope.Fchart = {
    series: ['Employer'],
    data: [
          {x:"abc",y:[450]},
          {x:"bcd",y:[500]},
          {x:"cds",y:[350]}
    ]
}

and you missing the chart type in <div>.

<div ac-chart="chartType" ... // have to replace the `chartType` with a chart type like `bar` , `pie`

then it should be like

<div ac-chart="'bar'".... //for bar chart. 

plunker

Upvotes: 1

Related Questions