Ext js update chart pie after filter

I have a problem with filtering the fields of a chart.
I have a chart that contains some fields.
The user can filter the chart diagram and select the fields that he wants to see.
The problem is that if there are 8 fields in the pie and the user selects only 6 fields, the filter filters only the data, but does not filter the fields either.

For example, if I have fields

{name:'Asia','data1':9, sex:'Male'}, {name:'Africa','data1':2, sex:'Male'}, {name:'Europe','data1':5, sex:'Female'}, {name:'USA','data1':3, sex:'Male'}, 

and I want to filter Asia, Africa and Europe, I can still see US name fields (without data).

Code:

 storeIng.filterBy(function(record,id){ var fieldName = record.get('name') for(var i = 0; i < fields.length; i++) { if (fields[i] === fieldName) return true; } return false; }); 

I also add screenshots to http://i45.tinypic.com/1eq74i.jpg after http://i45.tinypic.com/1z1zofq.jpg

+4
source share
1 answer

Since you did not get much code, try this code for reference and see where the error is. The filterBy function you wrote seems to be all right. It can also help others reading this if they are having problems filtering storage data.

  Ext.onReady(function(){ var data=[ {name:'Asia','data1':9, sex:'Male'}, {name:'Africa','data1':2, sex:'Male'}, {name:'Europe','data1':5, sex:'Female'}, {name:'USA','data1':3, sex:'Male'} ] var store = Ext.create('Ext.data.JsonStore', { fields: ['name', 'data1','sex'], data:data }); store.filterBy(function(record,id){ if(record.get('name')==="Asia") return true; }) Ext.create('Ext.chart.Chart', { renderTo: Ext.getBody(), width: 500, height: 350, animate: true, store: store, theme: 'Base:gradients', series: [{ type: 'pie', angleField: 'data1', showInLegend: true, highlight: { segment: { margin: 20 } }, label: { field: 'name', display: 'rotate', contrast: true, font: '18px Arial' } }] }); }); 
0
source

Source: https://habr.com/ru/post/1445333/


All Articles