Hi everyone,
I've been working for some time to try and remove the click event behavior on my chart legends. The default functionality for the legends on pie charts or series charts, is that if you click one of the legend items, it will remove it from your chart display. If you click on it again, it will return it back. For example, see the below chart with legend.
piechart.png
This is my current chart render code:
Code:
function showPieChart (elemId, storeData, wid, hei, style, isPercentage) {
Ext.BLANK_IMAGE_URL = '/newui_assets/images/x.gif';
Ext.require('Ext.chart.*');
var seriesColors = ["#ba999e", "#5e6668", "#c4bfa6", "#7ea9cc", "#dee3e6", "#937c5d"];
var chartStyles = chartStylesNormal;
var labelStyles = labelStylesNormal;
var legendPosition = 'bottom';
if (style == "mini") {
chartStyles = chartStylesMini;
labelStyles = labelStylesMini;
legendPosition = 'right';
}
Ext.define('Ext.chart.theme.themeNormal', {
extend: 'Ext.chart.theme.Base',
constructor: function(config) {
this.callParent([Ext.apply({
colors: seriesColors
}, config)]);
}
});
Ext.onReady(function(){
Ext.create('Ext.chart.Chart', {
renderTo: elemId,
width: wid,
height: hei,
animate: true,
store: storeData,
shadow:false,
theme: 'themeNormal',
legend: {
boxStrokeWidth: 0,
position: legendPosition,
labelFont: 'normal 9px Arial'
},
series: [{
type: 'pie',
field: 'count',
showInLegend: true,
tips: {
trackMouse: true,
dismissDelay: 0,
width: 140,
height: 28,layout: 'fit',
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('count') + ((isPercentage)?"%":"") + " " + storeItem.get('name') + ((storeItem.get('count')>1)?"s":""));
}
},
highlight: {
segment: {
margin: 5
}
}
}]
});
//Ext.Array.forEach(Ext.query(".x-hide-visibility"), function (item) { item.setAttribute("class", "x-hide-display"); });
});
}
I tried to use this fix which was suggested by someone else:
Code:
Ext.each(Ext.chart.legend.items, function(item) {
item.un("mousedown", item.events.mousedown.listeners[0].fn);
})
However, I got the following error when I tried that:
Uncaught TypeError: Cannot read property 'items' of undefined
Any help is really appreciated.
Thanks!