score:2
Accepted answer
you can use padding
property on the title
option to achieve that:
var ctx_age_range = document.getelementbyid('chart_age_range');
var mydoughnutchart = new chart(ctx_age_range, {
type: 'bar',
data: {
labels: ["<20", "20-29", "30-39", "40-55", ">56"],
datasets: [{
label: "cantidad",
backgroundcolor: ["#47b3d5", "#47b3d5","#47b3d5","#47b3d5","#47b3d5"],
data: [0.32,34.55,34.79,25.32,5.02]
}]
},
options: {
legend: {
display: false,
},
title: {
display: true,
text: 'casos por rango de edad',
fontsize:15,
color:"black",
padding: 30
},
scales: {
xaxes: [{
gridlines: {display: false},
ticks: {
stepsize: 1,
min: 0,
fontsize:12
},
barpercentage: 0.8,
categorypercentage: 1,
}],
yaxes: [{
scalelabel: {
display: false,
},
gridlines: {display: false,drawborder:false},
ticks:{
display:false,
},
}]
},
plugins: {
datalabels: {
display: true,
align: 'end',
anchor: 'end',
formatter: function(value, ctx) {
return value+'%';
},
color:'black',
font:{
size: 11
}
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.9.3/chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@0.7.0/dist/chartjs-plugin-datalabels.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<canvas id="chart_age_range" width="400" height="400"></canvas>
Source: stackoverflow.com
Related Query
- How to add margin bottom in Tittle ChartJS
- How to add ChartJS code in Html2Pdf to view image
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How to add space to the bottom of the chart in chartjs [angular]
- chartjs - how do I add border radius on bottom corners
- How to modify chartjs tooltip so i can add customized strings in tooltips
- How to add label for ChartJs Legend
- How to change the color of legend in chartjs and be able to add one more legend?
- How to add background color between two lines in yAxis Chartjs
- ChartJS version 3 how to add percentage to pie chart tooltip
- How to add background color between two specific lines in Chartjs 3.1
- How to add datalabels to chartJS on Primefaces
- How to add a Date Selector to Chartjs in the context of Vue.js
- How to add new data point and remove leftmost data point dynamically in Chartjs
- chartjs 2.7 how to add labels in center of horizontal bar graph
- How to add left padding for my charts done in ChartJs and my Google Map so it is not glued to the limit of the page on the left
- How to add additional label in the middle of each bar using ChartJS
- How do I add Date range filter in chartjs in the context of Vue.js
- ChartJS - How to add Text between Pie Chart and Legend
- How can I style ChartJS to always be at the bottom of a div?
- how to add extra label at zero levels in x-axis in chartjs
- How to modify chartjs tooltip to add customized attribute
- how to add color to each data in chartjs scatter plot
- How can I add functionality to Chartjs Doughnut chart custom legend
- How to remove legend at the bottom of chartjs doughnuts
- How to run Chart.js samples using source code
- How do I add JSON Data into ChartJS
- How to add dataset legend in chartjs tooltip
- how to add simple option to chartjs correctly
- How to add vertical line in bar chart using chartJs and ng2-charts?
More Query from same tag
- Vue Chart 3 - Doughnut Charts with Text in the Middle (Trouble registering a plugin)
- Chart.js - Scale of secondary y-axis?
- Show statistics in my diagram (php mysqli)
- Problem displaying two graphs on a single chart using javascript and chart.js
- Chartjs gradient background color based on min and max values
- Chart.js angular8 Y axis ticks
- Padding Between Pie Charts in chart js
- Chart.js xaxis formatter changes the value shown in the chart
- Chart.js LineChart how to show only part of dataset and support horizontal scrolling
- Chartjs with Backbone
- Bind Angular FormGroup to Chartjs data
- How to get Max Values of a Multidimensional Array for 30 Days
- Chart JS Legend Styling
- How to shorten Chart.js label
- Chart.js doesn't animate on first load
- chart.js not getting linked with online database and php
- Accordion won't take up height of chart for first click
- Assigning a value to an object w/bracket notation
- How do I make the Line in ChartJS not exceed the maximum of yAxes
- How to convert Json to Array In javascript for chart.js
- Chart.js - add gradient instead of solid color - implementing solution
- Display chart data based on API call
- Ng2-Charts in Angular: Is 'Auto' supported for display property of Axes
- Change the hover data value from to string
- I have a setInterval function that graphs.
- chartjs: How to create single outer border for stacked barchart
- Customize Pie Chart Legend in chart.js
- Chart.js how to set start and end values to plot
- How to create multi scale chart?
- Chartjs 2: Multi level/hierarchical category axis in chartjs