Buzzo
Buzzo

Reputation: 153

C3js - combination chart with data labels only for line

I want to create a combination chart with stacked bars + line using c3js. I don't want to see data labels on top of the stacked bars but I want to see them for the line. I know that flag "labels: true/false" is showing/hiding ALL the labels. Is it even possible to do something like this?

My code:

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 30, 20, 50, 40, 60, 50],
            ['data2', 200, 130, 90, 240, 130, 220],
            ['data3', 100, 230, 390, 440, 230, 120],
            ['line4', 430, 480, 630, 820, 450, 490]
        ],
        type: 'bar',
        types: {
            line4: 'line'
        },
        groups: [
            ['data1','data2', 'data3']
        ],
        labels: true
    }
});

Chart created:

Chart created by me

Desired Chart:

Desired chart

Upvotes: 3

Views: 1680

Answers (1)

mgraham
mgraham

Reputation: 6207

You can though set data label formatting per data series:

    labels: {
        format: {
            data3: d3.format(),
        }
    }

..and it seems omitting a format for a data series means the labels aren't drawn for that series.

http://jsfiddle.net/wn3vzn0k/424/

Upvotes: 2

Related Questions