João Martins
João Martins

Reputation: 1046

Add a title to C3.js chart legend

I am using c3js and I'm still new to this chart framework. I need to set a title to the series legend of my chart. How can I do this? Do I need to use D3 to implement this? I need something like this

Thanks in advance.

Upvotes: 1

Views: 2719

Answers (1)

Mark
Mark

Reputation: 108507

How about this mess:

var firstLegend = d3.select(".c3-legend-item");
var legendCon = d3.select(firstLegend.node().parentNode);
var legendY = parseInt(firstLegend.select('text').attr('y'));
legendCon
  .append('text')
  .text('Legend Title')
  .attr('y', legendY - 20);

Upvotes: 4

Related Questions