PDA

View Full Version : Hiding a series in a column chart



fordprefect
16 Feb 2012, 12:53 PM
Hi,

I'm attempting to hide a series in a column chart without much succcess. Here's how my chart series is defined:



series: [{
type: 'column',
axis: 'left',
highlight: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data1') + ' $');
}
},
label: {
display: 'insideEnd',
'text-anchor': 'middle',
field: 'data1',
renderer: Ext.util.Format.numberRenderer('0'),
orientation: 'vertical',
color: '#333'
},
xField: 'name',
yField: ['data1', 'data2']
}


I've been able to hide the first item in the series with:



chart.series.get(0).hideAll();


However I can't hide any other item in this series. When I query the series yField I see 2 items: 'data1', 'data2'

Does anyone know how I can hide the second yField item? Perhaps my series setup is incorrect.

Thanks.

mitchellsimoens
16 Feb 2012, 12:58 PM
Here is how the legend item does it when you click on it:


me.on('mousedown', function() {
if (!toggle) {
series.hideAll(index);
label.setAttributes({
opacity: 0.5
}, true);
} else {
series.showAll(index);
label.setAttributes({
opacity: 1
}, true);
}
toggle = !toggle;
}, me);

fordprefect
16 Feb 2012, 1:47 PM
Thanks Mitchell,

I was able to get the columns to hide like so:



chart.series.get(0).hideAll(0);
chart.series.get(0).hideAll(1);


Cheers.