-
24 May 2011 7:23 AM #1
ExtJS 4 Pie chart display with 0 Value
ExtJS 4 Pie chart display with 0 Value
Hi,
Just trying a Pie chart in ExtJS and got to know this. Why Pie chart will have a small line for 0 values. Please find the code below for more details.
Can somebody help out for this.
Thanks
Code:
<html><head>
test
<script type="text/javascript" src="/extjs4/bootstrap.js"></script>
<script type="text/javascript" src="/extjs4/src/core/src/env/FeatureDetector.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var store = Ext.create('Ext.data.JsonStore', {
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
data: [{
'name': 'January',
'data1': 0
}, {
'name': 'February',
'data1': 0
}, {
'name': 'March',
'data1': 0
}, {
'name': 'April',
'data1': 0
}, {
'name': 'May',
'data1': 20
}]
});
Ext.create('Ext.chart.Chart', {
renderTo: Ext.getBody(),
width: 800,
height: 600,
animate: true,
store: store,
theme: 'Category1',
legend: { // Pie Chart Legend Position
position: 'right'
},
series: [{
type: 'pie',
field: 'data1',
showInLegend: true,
tips: {
trackMouse: true,
width: 140,
height: 28
},
highlight: {
segment: {
margin: 5
}
}
}],
});
});
</script>
</head>
<body></body>
</html>
-
23 Feb 2012 9:04 PM #2
Pie Chart Labels are even shown on 0 values
Pie Chart Labels are even shown on 0 values
I am facing a similar problem. Labels on Pie Chart appear even if there is 0 value for it.
Any sort of help would be appreciated
-
28 Feb 2012 2:03 PM #3
Did you get a response for this issue ?
Did you get a response for this issue ?
The labels still get rendered and overlap even though the chart is not rendered for an empty dataset.
Is there a way to hide labels for an empty data set or a data set with some zero values ?
-
28 Feb 2012 9:20 PM #4
Chart Layout is fine as far as labels remain same. The ONLY solution I found if labels change is chart.redraw()
-
4 Apr 2012 6:13 PM #5
My solution
My solution
Code:... label: { display: 'middle', field: 'myValue', renderer: function (val) { return val > 0 ? val : ''; } } ...
-
20 Dec 2012 10:23 PM #6
Hi Brett,
Above mentioned code not help to hide zero value labels. can u tell me some other way to hide those labels(which are all having zero count) in pie chart.i attached the chart also.
-
4 Jan 2013 2:14 AM #7
It's relatively simple actually at least my implementation of it.
What you want to do in the label renderer is to check if the value the pie chart is based on is greater than zero and if it is then show the label.
I have the store defined as a variable in my code so I could reference is simply but otherwise you could use the Ext.getStore() method.
Code:renderer: function(value) { var m = pieStore.findRecord('name', value); return m.get('val') > 0 ? value : ''; }
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote