score:30
You need to wrap the title
object inside an options
object like
var myChart = new Chart(ctx, {
type: 'doughnut',
options: {
plugins: {
title: {
display: true,
text: 'TEST'
}
}
}
....
Here are the docs for a full list of all the options, chartjs:title
var data = [2137680, 6282693, 805566, 2568163, 598599, 3189284, 599112, 926340, 5548295, 11847685, 66445];
var labels = ["Management", "Finance", "Human Resources", "Business Development and Marketing", "Information Technology", "Professional Development and Training", "Knowledge Management", "Logistics", "Support", "Business Services", "Other"];
var bgColor = ["#878BB6", "#FFEA88", "#FF8153", "#4ACAB4", "#c0504d", "#8064a2", "#772c2a", "#f2ab71", "#2ab881", "#4f81bd", "#2c4d75"];
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'doughnut',
options: {
title: {
display: true,
text: 'TEST'
}
},
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: bgColor
}]
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<canvas id="myChart" width="400" height="400">
</canvas>
score:1
In your JSFiddle, you forgot to add options
.
The example in the documentation is:
options: {
title: {
display: true,
text: 'Custom Chart Title'
}
},
See this fiddle: https://jsfiddle.net/ha19ozqy/90/
score:1
You need to wrap the title
object inside the plugins
object and then plugins
inside options
.
Version: 3.7.1
var myChart = new Chart(ctx, {
type: 'doughnut',
options: {
plugins:{
title: {
display: true,
text: 'Title'
}
}
}
This will surely work!
score:2
Your title
property should come inside another property called options
. Try this.
options : {
title: {
display: true,
text: 'TITLE HERE'
}
}
You can check for some examples here as well.
score:4
Please try adding options object inside for title
https://jsfiddle.net/Jaffreena/ha19ozqy/93/
var data = [2137680, 6282693, 805566, 2568163, 598599, 3189284, 599112, 926340, 5548295, 11847685, 66445];
var labels = ["Management", "Finance", "Human Resources", "Business Development and Marketing", "Information Technology", "Professional Development and Training", "Knowledge Management", "Logistics", "Support", "Business Services", "Other"];
var bgColor = ["#878BB6", "#FFEA88", "#FF8153", "#4ACAB4", "#c0504d", "#8064a2", "#772c2a", "#f2ab71", "#2ab881", "#4f81bd", "#2c4d75"];
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: bgColor
}]
},
options: {
title: {
display: true,
text: 'Custom Chart Title'
}
}
});
Source: stackoverflow.com
Related Query
- ChartJs title not showing
- chartjs + Angular6 is not showing charts or any error
- ChartJS bar not showing up for simple data points
- Chartjs Graph is not showing in colorbox
- Chartjs bar dataset label not showing
- ChartJS / MomentJS - Unable to remove deprecation warning. Graph not showing in firefox/opera
- showing tooltips all the time in chartjs 2.4 not working
- Chartjs not working with d3 from csv source
- Chartjs not showing all data points
- ChartJS : It's not showing in html on Django
- Chartjs does not show on pdf in yii2 despite showing in html view
- Chartjs only showing dots, line not showing
- ChartJS yAxis showing not coherent data
- ChartJS plot not showing as it should be when toggling a grouped legend element
- ChartJS x axis title not visible when axis position is centered
- Scatter plot not showing anything chartjs needs some debugging
- Label is not showing in ChartJS
- ChartJS not showing data for time series bar chart
- Chartjs not showing chart
- ChartJS + jQuery = Chart not showing
- ChartJS custom doughnut chart not showing in version 2.6.0
- Dynamically loaded chart data not showing Chartjs React
- Chartjs v3 tooltip label not showing tooltip label color on custom calbacks
- Custom Legend ChartJS not showing the text decoration: line through
- ChartJS Bar Issue - Showing "zeros" and not center bars
- ChartJS hover tooltip colors not showing their correct color
- ChartJs bar not showing up
- ChartJS multichart graph not showing correctly legends
- My Chartjs is not updating after setstate full code attached Reactjs Update
- ChartJs tool tips not showing properly
More Query from same tag
- How to highlight a section of a stack in all bars in a stacked barchart in chartjs
- How to make a chart scroll horizontally (when using Chart.js)
- How can make my chart.js dynamic using data from database
- Calculate value in tooltip in ChartJS
- In Chart.js multibar graph, is there a way to highlight a single category?
- Cannot get react-chartjs to update
- Vue + chartjs : Nearest point on hover tooltip not working
- plot a bar chart.js time series
- Chart.js updating data
- Different labels in tooltip with chartjs
- Chart.js - Add gradient to bar chart
- Doughnut chart, in some cases if quantity is 1, its showing without back ground color, but color shows correctly while hovering
- chartjs table each making series not proceeding to next tr
- How can I change the legend label without affecting my tooltip label?
- Add custom data scale to Chart.js
- Chart js - Draw center of each bubbles of a bubble chart
- How can I filter these data per month?
- Chart.js tooltips callback function with pie charts
- How to get data of json file for chart.js diagram
- Chartjs Percents in Legend
- ChartJS: add a clickable text in title
- How can I fix the offset of the gradient to be aligned with the chart points(chart.js)?
- Error when changing data after migrating to vue-chartjs 4
- Change chart.js options based on window width
- How to grouping Label In Char JS
- Chart.js Y Axis Wrong Step Count
- Why can I not see a data value when hovering over a point on the radar chart?
- Draw Line Chart Using Chart.js
- React-Chart.js : How do I increase the space between the legends and chart?
- chart.js increase value on click