score:2
actually you can do this with a simple extension of the chart type you are using and moving your draw code to inside the draw override
preview
code
chart.types.doughnut.extend({
name: "doughnutalt",
draw: function () {
chart.types.doughnut.prototype.draw.apply(this, arguments);
this.chart.ctx.textbaseline = "middle";
this.chart.ctx.fillstyle = 'black'
this.chart.ctx.font = "50px roboto";
this.chart.ctx.textalign = "center";
this.chart.ctx.filltext(distributionchartdata[3] + " %", 135, 120);
this.chart.ctx.font = "20px roboto";
this.chart.ctx.filltext((distributionchartdata[0] + distributionchartdata[1] + distributionchartdata[2]) + " responses", 135, 160);
}
});
var piechart = document.getelementbyid("piechart").getcontext("2d");
new chart(piechart).doughnutalt(piedata, {
percentageinnercutout: 80, animationeasing: "easeoutquart"
});
fiddle - http://jsfiddle.net/p979zylj/
score:0
i think you can set option: {animation: false}
on your chartjs settings to solve this.
score:2
chartjs will redraw itself as needed (for example when displaying tooltips), so you must redraw your "% and responses" text whenever chartjs refreshes (redraws) the chart.
you can set chartjs's 'onanimationcomplete' callback to draw your call your "% and responses" text when chartjs has completed it's own drawing and animating.
[ addition: ]
i've taken a look at the chartjs source code and the issues on github.
there is currently no way within the chartjs api to trigger redraws of your custom text (your "% and responses") after a tooltip closes.
one workaround would be to use css to place a div with your "% and responses" over the chart.
Source: stackoverflow.com
Related Query
- canvas fill text vanishes when hovering over chartjs pie chart
- Chart.js - Fill Text only appearing when hovering over one part of the doughnut
- Chartjs Bar Chart showing old data when hovering
- Moving vertical line when hovering over the chart using chart.js
- chartjs datalabels change font and color of text displaying inside pie chart
- ChartJs line chart repaint glitch while hovering over
- chart.js bar chart datalabel vanishes on hovering over chart
- Highlight chart element when hovering over its corresponding legend Item
- Problems hovering over ChartJS bar chart after being redrawn
- ChartJS pie chart with simple parsing options doesn't render, only works when set as bar/line chart
- ChartJS: Highlight dataset in a stacked bar chart when hovering over the legend?
- Chartjs Bar Chart showing old data when hovering when use of ajax
- ReactJS - Moving vertical line when hovering over Line chart using chart.js v3.7.1
- Show/hide All nested data in ChartJS Pie chart when outer is shown/hidden
- ChartJs does not render chart when binding canvas id in Angular
- ChartJS - How to add Text between Pie Chart and Legend
- Moving vertical line when hovering over the chart using chart.js in v2.9.4
- Drawing to canvas on click clears text when mouse leaves the chart
- Charts with previous data appear when hovering the cursor over the chart in Chart.js
- Trigger bar/pie graph highlight when hovering over an external element [chart.js / chart js] [AngularJS] [angular-chart.js]
- place images over pie chart slices using chartjs
- Chartjs random colors for each part of pie chart with data dynamically from database
- chartjs tooltip is cut off when out of canvas
- chartjs show dot point on hover over line chart
- Display values outside of pie chart in chartjs
- How to change the cursor to a pointer when I hover over a bar in a ChartJS bar chart?
- ChartJs canvas showing previous graph when changing Graph types
- ng2-charts customize data and whole html content of tooltip displayed when hovering on bar chart
- Why can I not see a data value when hovering over a point on the radar chart?
- ChartJs line chart - display permanent icon above some data points with text on hover
More Query from same tag
- Passing data from Python to JavaScript to plot Chart.js
- How to call a JavaScript file inside a PHP if/else statement?
- Print pie chart in chartjs
- Chart.js have the y-axis step from 20 to 1 (instead of 1 to 20)
- Angular-chart / line chart with multiple horizontal lines (margins)
- Chart.Js : How to change the color of a point, based on a third data
- Why ChartJS's Bar Chart does not render bar for a specific value?
- Remove Decimal like " [Decimal('1220'), Decimal('160')] "from Django Queryset results
- How to Increase the label font size and decrease the size of my pie using chart.js?
- Show bar with zero value in ChartJs v2
- Chart.JS, date issues when upgrading to v3
- White space at start and end of data with time scale in chart.js
- How do I change the appearance of tooltips with mode: index in Chart.js
- Chart.js custom tooltip events
- Django 1.11 - child template not inheriting from parent
- Chart.js line graph-removing labels on the line
- Can't render two charts on the same page from chart.js
- Keep the Y axis fixed when the chart scrolls horizontally, regardless of DPI settings?
- Problem with primeNG chart: Module not found: Error: Can't resolve 'chart.js/auto'
- How to disable Chart JS tooltip when there is no value?
- ChartJS - Labels background
- what is wrong with my code ? java script chart position
- Aligning zero on y axis to the labels on x axis of line chart in chartjs
- How can I show "No Data" message in Pie Chart when there is no data using VueJS?
- Chart.js - Increase spacing between bottom legend and chart
- how to reset the graph/chart after zoomin, pan using chartjs
- Loop Dataset ChartJS Javascript
- How to set responsive width and height of canvas?
- ChartJs how can I move bar into new group?
- Animate Chartist on show