Vinoth
Vinoth

Reputation: 1103

D3 Dashboard chart not working properly

Hi i am using D3 Dashboard chart.

This is my reference D3 Dashboard Chart.

https://plnkr.co/edit/Q8OqJF3pOt8eGmwlreaf?p=preview

Here all the data's are coming from variable. For my usage I want to get the data from json file. I have changed that also.

But the filter function is not working here. "if i clicked the pie chart, the data is not filtered. if i hard code the filter value means it will filter as per the pie chart value" can any one tell me how to correct my mistake.

Here is my plunker code.

https://plnkr.co/edit/fAl9l9INrFmxO94yHaV4?p=preview

 d3.json("d1.json", function(datasetBarChart){

    // set initial group value

var group = "MAB"; // if i changed group value as per the pie chart it will filter in the bar chart.

function datasetBarChosen(group) {
debugger;

    var ds = [];
    for (x in datasetBarChart) {
         if(datasetBarChart[x].group==group){
            ds.push(datasetBarChart[x]);
         } 
        }
    return ds;
}

Thanks

Upvotes: 0

Views: 82

Answers (1)

Gunner
Gunner

Reputation: 746

The bar chart does not update because updateBarChart function is in the scope of d3.json("d1.json", function(datasetBarChart){}.

function up(d, i) {
    updateBarChart(d.data.category, color(i));
    updateLineChart(d.data.category, color(i));
}

To work around this, make the call for data and pass it to the render functions.

Updated plunker: https://plnkr.co/edit/L18QvDQ2FFvM29wJkx4i?p=preview

Upvotes: 1

Related Questions