Billboard.js: Highlighting a specific data point

Created on 9 Oct 2017  路  2Comments  路  Source: naver/billboard.js

Description

Is there a way to highlight one or more data points with a different colour. Imagine a bar graph that is all black with 5 bars where 2 of the bars are a different colour?

I've tried passing an array to the data: { color: array } but it seems as though it can only take one colour.

Alternatively, if there's not way to colour specific data points, then perhaps there's a way to use two data groups but make them not dodge each other (then use 0 points for all except those that you want to colour).

question

Most helpful comment

In that case, you can use data.color function to change the color of specific data points.

    data: {
        color: function(color, d) {
            // will make 3rd and 4th data as red color
            if (d.index && d.index == 2 || d.index == 3) {
                color = "red";
            }

            return color;
        }
    }

image

Check out the online working demo:

All 2 comments

In that case, you can use data.color function to change the color of specific data points.

    data: {
        color: function(color, d) {
            // will make 3rd and 4th data as red color
            if (d.index && d.index == 2 || d.index == 3) {
                color = "red";
            }

            return color;
        }
    }

image

Check out the online working demo:

Excellent. Feel free to close.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drazik picture drazik  路  4Comments

flipcode1973 picture flipcode1973  路  5Comments

creage picture creage  路  4Comments

AyshvaryaLaxmiK picture AyshvaryaLaxmiK  路  5Comments

mafar picture mafar  路  4Comments