Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
mw-chart is an AngularJS module that make ChartJS available inside AngularJS.
You can install this package either with npm
or with bower
.
npm install mw-chart --save
bower install mw-chart
Once the script is included in your html file, simply include the module in your app:
angular.module('myApp', ['mw-chart']);
And use the included 'mwChart' directive thusly:
<mw-chart options="chartOptions"></mw-chart>
You can freely use the ChartJS documentation for the options attribute.
$scope.chartOptions = {
type: 'bar',
data: {
datasets: [{
borderWidth: 1,
data: [
{"x":"2018-05-01","y":"58"},
{"x":"2018-06-01","y":"60"}
]
}]
},
options: {
scales: {
xAxes: [{
type: 'time',
time: {
displayFormats: {
month: 'MM.YYYY'
},
unit: 'month'
},
offset: true,
ticks: {
source: 'data',
}
}],
},
}
};
Everything beside the "data" parameter will be automaticly updated. This is duo the fact that inside the "data" parameter is a reference to the canvas element inside the HTML. Therefore it can't be watched by AngularJS.
To Update your data you just need to trigger the update function. It will be availabe on the "chartOption" variable after the DOM is rendered.
$scope.chartOptions.data_update();
If you want to use ChartJS without the directive or set the default values you can use the factory "$chart".
angular.module('myApp').controller('MainCtrl', ['$scope', '$chart', function($scope, $chart){
$chart.defaults.global.legend.display = false;
}]);
$chart was also extendet with the function create_random_color()
to create a random color for you.
FAQs
Lightwight AngularJS module that connects ChartJS with AngularJS
The npm package mw-chart receives a total of 1 weekly downloads. As such, mw-chart popularity was classified as not popular.
We found that mw-chart demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.