Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a title to c3.js chart

Can any one suggest me the way of adding title to the C3.js line and bar charts ? I have got the following sample but it is for gauge chart. For any c3 chart is there any option to set the chart title?

donut: {
  title: 'Title'
}
like image 904
smart987 Avatar asked Feb 23 '15 05:02

smart987


People also ask

How do you give a title in Chartjs?

The example below would enable a title of 'Custom Chart Title' on the chart that is created. const chart = new Chart(ctx, { type: 'line', data: data, options: { plugins: { title: { display: true, text: 'Custom Chart Title' } } } }); Copied!

What is C3 Javascript?

This library is used to create a dynamic and interactive data visualizations. C3 is a library build on top of D3. C3 is d3 based reusable chart library and most important advantage of using c3 is that you don't have to know D3 or write those long codes!.

What is C3 and D3?

js is a JavaScript library for manipulating documents based on data. c3. js is a Javascript library which makes it easy to generate D3-based charts (less code to write). highchart is a Javascript charting framework.


2 Answers

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

like image 100
dbone Avatar answered Nov 03 '22 15:11

dbone


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");
like image 9
Sean Avatar answered Nov 03 '22 15:11

Sean