Anson Aştepta
Anson Aştepta

Reputation: 1145

The C3js tooltip values

So far i have done a chart like this in the jsfiddle : http://jsfiddle.net/q8h39/111/

Which contain some customize tooltip contents in each plot, since i want to add extra data in to the tooltip, i had tried to use the "indexOf()" method to do the work, but no luck.

tooltip: {
                        format: {
                            title: function(s) {
                            var indOfVal = coverageArr.indexOf(s);
                            return engagementArr[indOfVal - 1];
                            },

                           name:function(){
                            return engagementArr[0]; 
                           },

                            value: function(x) {
                            //var indOfVal = coverageArr.indexOf(x);
                            return engagementArr;//[indOfVal - 1]
                            },
                        },

                    },

I am trying to apply the values like how i apply names into the title section, but it's not working.

Am i able to change the tooltip color as well? different color for each plot

I found myself a solution of this!

Since the c3 library function (name, ratio, id, index) , we can just use the index in order to insert data to each of the datas:

 value: function(value, ratio, id, index) {
        return engagementArrNum[index - 0];
            }

The code will be like this, getting the given index and pass data in to each tooltip!

Upvotes: 1

Views: 1843

Answers (1)

Anson Aştepta
Anson Aştepta

Reputation: 1145

Since the c3 library function (name, ratio, id, index) , we can just use the index in order to insert data to each of the datas:

 value: function(value, ratio, id, index) {
        return engagementArrNum[index - 0];
            }

The code will be like this, getting the given index and pass data in to each tooltip!

Upvotes: 0

Related Questions