score:67
Since charting involves heavy DOM manipulation, directives are the way to go.
Data can be kept in the Controller
App.controller('Ctrl', function($scope) {
$scope.data = [[[0, 1], [1, 5], [2, 2]]];
});
And you can create a custom HTML tag1 specifying the model you want to get data from
<chart ng-model='data'></chart>
which angular can compile through a directive
App.directive('chart', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
var data = scope[attrs.ngModel];
$.plot(elem, data, {});
elem.show();
}
};
});
This process is similar for most plugins that modify the DOM.
-*-
Also, you can watch for changes in the chart's underlying data and redraw it, so this way you can grab data through the $http service from your controller and update the view automatically. This can be achieved by modifying the linking function in the directive definition object
var chart = null,
opts = { };
scope.$watch(attrs.ngModel, function(v){
if(!chart){
chart = $.plot(elem, v , opts);
elem.show();
}else{
chart.setData(v);
chart.setupGrid();
chart.draw();
}
});
Notice the usage of Flot's API within the directive to achieve what we want.
1 Can be an attribute too.
score:1
To use jQuery plugins with angularJS, you have to wrap them in directives, you can find some exemples of jQuery plugins directives by reading the source code of angularUI directives: https://github.com/angular-ui/angular-ui/tree/master/modules/directives
Source: stackoverflow.com
Related Query
- How to Integrate Flot with AngularJS?
- How to integrate highchart range slider in angularjs
- How to initiate AngularJs directive when its name is set with ng-class
- How to have multiple highcharts with different series data in vuejs without repeating code
- How to properly integrate google spreadsheets with highcharts?
- How to integrate Highmap chart with angular 5 Application?
- How to work with Highcharts in AngularJS
- Highcharts - how to have a chart with dynamic height?
- How to use highcharts with angular 5?
- How to save an image of the chart on the server with highcharts?
- How can I read an Excel File with JavaScript (without ActiveXObject)
- How to include highcharts with bower?
- how to import highcharts with webpack and babel
- How to prevent highcharts from shortening labels with ellipsis
- bootstrap data-toggle="tab" - how to make a tab active with a JS call
- How to export the whole page or html content with Highcharts not just the chart?
- How to show a column with the value Zero in Column chart in Highcharts?
- How To Use Epoch Time With Highcharts Series Data?
- How to create a new Highstock chart with new Highchart and not jquery?
- How to get rangeSelector to work with HighCharts
- Highcharts : Chart with drilldown how to obtain click event of drill up button
- How to display highchart y axis with constistant data
- How to use highcharts with princeXML?
- How to import Proj4js to use with Highmaps?
- AngularJS watch array of objects with index
- How to structure Angular with Highcharts and lots of dynamic data
- How to add mean line in a boxplot made with highcharter?
- How to handle Highcharts events from an AngularJS directive?
- How to display highcharts in ng-repeat angularjs
- How can I configure the legend with a specific height in highstock?
More Query from same tag
- GWT - Adding a button to HighCharts
- jquery show() not displaying properly for highcharts graph
- Highcharts xAxis datetime from start
- how to import highcharts with webpack and babel
- how do i redraw only the Highchart with new API that depends on my Select Option Parameter?
- HighStock baseSeries value is not getting updated
- Add null values to Array Javascript
- How to make color bar above navigator in Highstock?
- Highchart Heatmap shows index number in YAxis
- Change yAxis values in Compare multiple series highstock for showing point value instead of percentage change value
- How to show series dataLabels inside the Highchart pyramid in angular
- Highcharts dual yaxis scaling issue
- Highcharts angular 2 with observables http request
- Can't display extra tooltip data in price history chart
- Highcharts navigator padding generating new tick
- creating a bar chart using Highcharts with React - getting an error that rendering div isn't found
- Highcharts X axis categories name gets only shows 1 character
- Custom SVG symbol using HighCharts in Angular
- Is it possible to have synchronized charts with error lines?
- Heatmap With Custom Data Cannot Display anything
- Format of JSON output not working
- How to place 2 div one next the other one
- HighChart son data is not displaying on webpage
- Highcharts internal or PHP solution to have equal year distance on x-axis?
- Is it possible to define custom technical indicators, that takes 2 series as input?
- Highcharts drill down to detailed graph
- How to get columns category name on hover in highcharts
- Highcharts - multiple charts
- Highchart and HTMLCanvas
- Need to change title color donut highchart