giulio
giulio

Reputation: 659

Choosing the data to display in d3

How can I make a data visualization in d3 such that the data loaded changes when selecting an attribute? For example, if I have data that is a function of location, then I could select the location for which to display the data. The closest example I found was update, but then I cannot choose the data set to display.

Upvotes: 1

Views: 93

Answers (1)

aberna
aberna

Reputation: 5814

To obtain such level of interaction, you can focus on the library C3.js which is based on D3.

C3 provides a variety of APIs and callbacks to access the state of the chart. By using them, you can update the chart even if after it's rendered.

A sample of code could be as this one:

var chart = c3.generate({
    bindto: '#chart',
    data: {
      columns: [
        ['data1', 30, 200, 100, 400, 150, 250],
        ['data2', 50, 20, 10, 40, 15, 25]
      ]
    }
});

By C3 definition both data1,data2 will be interactive elements you can deal with.

Documentation here: http://c3js.org/

Upvotes: 1

Related Questions