How can I add a title to c3.js chart

a 夏天 提交于 2019-12-04 22:48:13

You'd need to fall back to using D3 to add a chart title. Something like:

d3.select("svg").append("text")
    .attr("x", 100 )
    .attr("y", 50)
    .style("text-anchor", "middle")
    .text("Your chart title goes here");
dbone

This was a top google result, so I thought I'd add that this is now part of the library:

title: {
  text: 'My Title'
}

More info @ https://github.com/masayuki0812/c3/pull/1025

Muthamil

I am using this code for my chart.

Code:

var chart = c3.generate({
        data: {
            columns: [
                ['Monday', 70],
                ['TuesDay', 20],
                ['Wednesday', 30],
                ['Thursday', 50],
                ['Friday', 100]
            ],
            type: 'donut'
        },
        donut: {
            title: "usage "
        }
    });

Result :

also couldn't find a way and ended up writing the title as the unit and editing the label.

gauge: {
        label: {
            format: function(value, ratio) {
                return "%"+value;
            },
            show: true // to turn off the min/max labels.
        },
    min: 0, 
    max: 100, 
    units: "Overall Profit"
//    width: 39 // for adjusting arc thickness
    },
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!