Drupal and Chartjs

Here is the snippet I used to describe how to load a Chartjs-based chart within a Drupal installation (function ($) { Drupal.behaviors.mymodule = { attach: function (context, settings) { $(document, context).ready(function () { var url = "http://localhost/test7/myweb/get_data"; $.getJSON( url, function(data) { var ctx = $("#myChart").get(0).getContext("2d"); var myLineChart = new Chart(ctx).Bar(data, {scaleFontSize:13,scaleFontColor:"#ffa45e"}); }); }); } }; })(jQuery); http://localhost/test7/myweb/get_data is the URL where Json data comes. "#myChart" is the ID of canvas element where chartjs will display the bar chart.
Etiquetas