score:6
Accepted answer
Complementing to answers and comments of others, I get this solution:
var MyChartView = Backbone.View.extend({
template: _.template($('#myChart-template').html()),
render: function(){
$(this.el).html(this.template());
var data = ...
var options = ...
var ctx = $('#myChart', this,el)[0].getContext("2d");
var myLineChart = new Chart(ctx).Line(data, options);
}
Hope this help you.
score:0
Since document.getElementById("myChart")
, is unable to find the canvas/myChart
as it is within the script tag.
Try this,
var ctx = $($('#myChart-template').html()).children('#myChart').get(0).getContext("2d");
Hope this solves the issue. :)
Source: stackoverflow.com
Related Query
- Chartjs with Backbone
- Chartjs not working with d3 from csv source
- Updating Chartjs to 2.5 with custom code
- Custom Legend with ChartJS v2.0
- Chartjs random colors for each part of pie chart with data dynamically from database
- ChartJS New Lines '\n' in X axis Labels or Displaying More Information Around Chart or Tooltip with ChartJS V2
- ChartJS - Draw chart with label by month, data by day
- Display line chart with connected dots using chartJS
- react-chartjs-2 with chartJs 3: Error "arc" is not a registered element
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Show bar with zero value in ChartJs v2
- Chartjs linechart with only one point - how to center
- How to fix chart Legends width-height with overflow scroll in ChartJS
- ChartJS - Donut charts with multiple rings
- Chartjs v2 xAxes label overlap with scaleLabel
- Updating chartJS with dynamic data
- ChartJS bar chart with legend which corresponds to each bar
- ChartJS with AngularJS - Canvas won't display anything
- Vuejs with ChartJS populate from API
- ChartJS - Line Chart with different size datasets
- Usage of ChartJS v3 with TypeScript and Webpack
- Chartjs - data format for bar chart with multi-level x-axes
- implement chartjs zoom with buttons
- Draw two plots using chartjs over one another with transparency
- Is it possible to combine two Y axes into a single tooltip with ChartJS 2?
- ChartJS - Line chart issue with only 1 point
- Horizontal bar with multiple sections in ChartJs
- Add zoom event handler to charts for chartjs with chartjs-plugin-zoom
- ChartJs line chart - display permanent icon above some data points with text on hover
- Create a rounded bar graph with Angular and chartJS
More Query from same tag
- Format x axis to show percent with Primefaces/Chartjs ScatterChart
- How to show the data labels without hovering the mouse on the bubbles
- Testing Chart.js with Jest/Enzyme - Failed to create chart: can't acquire context from the given item
- Angular Overlapping bars using chart.js
- ChartJS - Show percentage base on data on hover (AngularJS)
- JavaScript Chart.JS - Custom tooltips to add description of specific data point when hovering
- How to send an array of object as a prop?
- Is it possible to change chartjs line value in one column ? No transition
- Chartjs Line Color Between Two Points
- Chart.js and Angular - Click Event on Chart
- Chart,js Pie Chart can the gap between a pie chart and the legend be adjusted
- how to use javascript library in dart
- Make time series show last date in axis?
- Multipe doughnut charts on one page with text in center using Chart.js
- Transform JSON data for ChartJS
- Destroy chart.js bar graph to redraw other graph
- break y axis in line chart chart.js
- React js with react-chart js, does not render doughnut chart
- Chartjs Different Fill Color For Overlap Area
- How to set the pointDot option on combo stacked bar-line chart
- Place Text in Chart-Canvas Area in ChartJS
- How can I display the percentage symbol inside the chartjs?
- Automatically update ChartJS with Knockout data-bind
- Setting default to 0 in vuechart.js HorizontalBar
- How to add new x axis in chart JS?
- Chart.js charts not rendering data until I inspect element, is it because of async?
- React - How can I pass API data from one component to another in a different js file?
- how to make chartjs columns smaller in width for bar chart?
- How to set Json data to chart.js bar
- ng2-charts access chartjs object to apply chartjs functions