javascript - dc.js chart redrawing with new group function with click event -
i trying redraw dc.js charts new groups when other chart library click event.but doesnt redraw.
here javascript codes:
var donemchart = dc.rowchart('div#donem'), hospitaltypechart = dc.rowchart('div#hospital_type'), ckyshospitalclasschart = dc.rowchart('div#ckys_hospital_class'), ckyshospitaltypechart = dc.rowchart('div#ckys_hospital_type'), hospitalhealthregionchart = dc.rowchart('div#hospital_health_region'), hospitalrolechart = dc.rowchart('div#hospital_role'), hospitalschart = dc.rowchart('div#hospitals'); d3.json('tsim.json',function(data){ var ndx = crossfilter(data); var = ndx.groupall(); //define crossfilter dimensions var donemdim = ndx.dimension(function(d){ return d.donem}), hospitaltypedim = ndx.dimension(function(d){ return d.kurum_turu}), ckyshospitalclassdim = ndx.dimension(function(d){ return d.ckys_kurum_turu}), ckyshospitaltypedim = ndx.dimension(function(d){ return d.ckys_kurum_tipi}), hospitalhealthregiondim = ndx.dimension(function(d){ return d.saglik_bolgesi}), hospitalroledim = ndx.dimension(function(d){ return d.hastane_rol}), hospitalsdim = ndx.dimension(function(d){return d.hastane}) ; var donemgroup = donemdim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitaltypegroup = hospitaltypedim.group().reducesum(function(d){return d.toplam_muayene_say}), ckyshospitalclassgroup = ckyshospitalclassdim.group().reducesum(function(d){return d.toplam_muayene_say}), ckyshospitaltypegroup = ckyshospitaltypedim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalrolegroup = hospitalroledim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalsgroup = hospitalsdim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalhealthregiongroup = hospitalhealthregiondim.group().reducesum(function(d){return d.toplam_muayene_say}); donemchart .width(400) .height(300) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(donemgroup) .dimension(donemdim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); hospitaltypechart .width(400) .height(300) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(hospitaltypegroup) .dimension(hospitaltypedim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return d.value; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); ckyshospitalclasschart .width(400) .height(300) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(ckyshospitalclassgroup) .dimension(ckyshospitalclassdim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); ckyshospitaltypechart .width(400) .height(500) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(ckyshospitaltypegroup) .dimension(ckyshospitaltypedim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); hospitalhealthregionchart .width(400) .height(500) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(hospitalhealthregiongroup) .dimension(hospitalhealthregiongroup) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); hospitalrolechart .width(400) .height(500) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(hospitalrolegroup) .dimension(hospitalroledim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); hospitalschart .width(1000) .height(25000) .margins({top: 0, left: 0, right: 0, bottom: 0}) .group(hospitalsgroup) .dimension(hospitalsdim) .ordinalcolors(['#e89f00']) .label(function (d) { return d.key; }) .title(function (d) { return ""; }) .ordering(function(d) { return -d.value; }) .valueaccessor(function(p) { return p.value; }) .elasticx(true) .xaxis().tickformat(); chart.addlistener("clickgraphitem", function(event){ if(event.item.datacontext.d_type==1){ var donemgroup = donemdim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitaltypegroup = hospitaltypedim.group().reducesum(function(d){return d.toplam_muayene_say}), ckyshospitalclassgroup = ckyshospitalclassdim.group().reducesum(function(d){return d.toplam_muayene_say}), ckyshospitaltypegroup = ckyshospitaltypedim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalrolegroup = hospitalroledim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalsgroup = hospitalsdim.group().reducesum(function(d){return d.toplam_muayene_say}), hospitalhealthregiongroup = hospitalhealthregiondim.group().reducesum(function(d){return d.toplam_muayene_say}); dc.redrawall(); }else if(event.item.datacontext.d_type==2){ var donemgroup = donemdim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), hospitaltypegroup = hospitaltypedim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), ckyshospitalclassgroup = ckyshospitalclassdim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), ckyshospitaltypegroup = ckyshospitaltypedim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), hospitalrolegroup = hospitalroledim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), hospitalsgroup = hospitalsdim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}), hospitalhealthregiongroup = hospitalhealthregiondim.group().reducesum(function(d){return d.toplam_a_grubu_ameliyat_say}); dc.redrawall(); } dc.redrawall(); }); dc.renderall(); });
when click chart getting data type after cheking data type in chart listener function.and grouping dimension new group.when consol logged new groups show doesnt effect redrawing charts.
what can problem? how can solve this?
thanks
you've reassigned reference of hospitaltypegroup
variable (for example) different object. chart still holding reference old object. have reset group on hospitaltypechart
hospitaltypechart.group(hospitaltypegroup)
, re-render. (i don't think redrawing work here in lot of cases.)
Comments
Post a Comment