height attributes of the
<canvas> element are unitless, so use:
template: '<canvas width="100" height="100" style="width:100px; !important height:100px; !important"></canvas>'
I found similar behaviour with Aurelia (rather than Angular) - it didn't like rending the chart inside an element with a custom name, in your case "answers-plot". With Aurelia, I can just add "containerless" to my custom element and it works. I'm not sure with Angular directives - maybe replace:true, or transclude:true in the directive options?
I encountered the same problem the other day.
And I found that:
The parent of
<answers-plot>, and the
<answers-plot> 's width and height are 0. It seems that
Chartjs resizes its chart according to the size of the parent element of
<canvas> which causes the width and height of the canvas to be 0.
I used a
<div> to wrap the
<canvas> in my directive's template and gave a non-zero size to the
Chartjs's options) to
false, and the problem is solved.
- Why would a ChartJS chart end up with width 0 and height 0?
- React chart : prevent chart's canvas scaling with height and width
- Bar chart with min height and zero values - ChartJs
- ChartJS - would like to create a mixed chart with horizontal Bar and a dot to represent the answer from the current user
- Chartjs 2 - Stacked bar and unstacked line on same chart with same y axis
- Chart.js: width and height of a pie chart not respected
- How to get the actual chart width and height in chart.js
- ChartJS (React) Line Chart - How to show single tooltip with data and labels from 3 (multiple) dataset?
- Keep chart.js doughnut with fixed width and height centered in container
- Chartjs - Set start and end value into a Bar Chart
- I can not properly re scale <canvas> with width and height attributes
- How to reuse a Chartjs Chart component in with different Data and get past the **Canvas is already in use** error?
- Unable to set width and height on canvas in chart js
- How to make a chart with chartjs and Angular?
- Trying to export chart with Chartjs and React but getting erorr
- attempting to change height and width of canvas for chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Chartjs - Doughnut chart with multi layer and running value
- Chartjs create chart with big data and fixed labels
- How to shrink the height and increase the line width of a custom Chartjs horizontal line?
- Prevent size of canvas chart js to equal window height and width
- ChartJs - width scale of chart area and label area
- Setting width and height
- 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
- chartjs datalabels change font and color of text displaying inside pie chart
- How to fix chart Legends width-height with overflow scroll in ChartJS
- Chart.js Mixed Bar and Line chart with different scales
More Query from same tag
- How to use set the color for each bar in a bar chart using chartjs?
- How to manipulate data in react-chartjs-2
- Chart.js not height responsive
- Including Chart.js in a webpage without node.js and without CDN
- Change tooltips title at chart.js?
- ChartJS using multiple Y axes
- Chart.js not rendering chart with data from mySQL database
- Chart.js pie chart overflowing div
- Laravel passing orders to Chart.js
- Implementing hover callback in Chart.js
- Charts in wicket
- Unable to install chartjs-node with npm, due to file cairo.h missing/Failed at the email@example.com install script
- How to increase space between label and chart area in chart.js
- How can I show Bootstrap modal when on click in individual bars in chart.js
- How to prevent tick labels from "jumping" when drawn with ChartJS BeforeDraw
- How do I make a pie chart showing number of people in an age group with JSON and ChartJS?
- How to order tooltip values from the biggest to the smallest
- The 3rd dataset not showing in canvas
- Using lodash to prepare data for "last day user registration" chart
- Chart.js offine mode
- Display two line graphs with data starting at different points
- Chartjs: Multiple data values for the same label
- Remove zero values from tooltip
- Canvas doens't display in SAPUI5
- Replacing data chart.js and reloading chart [PHP/Js/AJAX]
- Fetch more data for line chart onZoom/onPan issues
- How to change colour of specific xAxis label in charts js
- Vuechart js not rendering on a component
- Unable to separate elements of JSON