Hello,
We are planning to remove zero values fromn tha chart. see the grid and chart in attached image. Right now alignment is not proper and X values for some series are not showing.
Is there any way to hide zero values from chart?
Regards
Shibu
Indus Systems Inc
Hide Zero Values
-
- Newbie
- Posts: 9
- Joined: Wed Nov 09, 2011 12:00 am
Hide Zero Values
- Attachments
-
- Picture1.png (83.18 KiB) Viewed 13625 times
Re: Hide Zero Values
Hi Shibu,
I'm trying to reproduce the situation with the code below:
But it seems to give me the expected result:
If that's not what you want, could you please try to explain how do you exactly want the 0 values to be drawn?
I'm trying to reproduce the situation with the code below:
Code: Select all
ThemesList.applyTheme(tChart1.getChart(), 1);
tChart1.getAspect().setView3D(false);
Bar occupi = new Bar(tChart1.getChart());
Bar vacant = new Bar(tChart1.getChart());
occupi.setColor(Color.BLUE);
vacant.setColor(Color.RED.applyDark(20));
occupi.add(2);
occupi.add(1);
occupi.add(3);
occupi.add(0);
vacant.add(5);
vacant.add(0);
vacant.add(9);
vacant.add(3);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 9
- Joined: Wed Nov 09, 2011 12:00 am
Re: Hide Zero Values
Hello, Yeray
Actually, We have to hide zero from the chart and that we got. But right now that series values with zero showing as empty in chart. As we have lot of series in this chart and there may exists only some item with zero values but it could be different for each category.
For e.g.
Series 1 has 1, 5, 0, 4, 0, 8, 3, 0
Series 2 has 0, 3, 1, 0, 2, 0, 3, 8
....
.....
While we are creating chart using addNull for zero values our previous problem was solved. but it take space for that series in each category. If we can trim that space, it can avoid more horizontal panning in chart
See attachment for more
Regards
Shibu
Indus Systems Inc
Actually, We have to hide zero from the chart and that we got. But right now that series values with zero showing as empty in chart. As we have lot of series in this chart and there may exists only some item with zero values but it could be different for each category.
For e.g.
Series 1 has 1, 5, 0, 4, 0, 8, 3, 0
Series 2 has 0, 3, 1, 0, 2, 0, 3, 8
....
.....
While we are creating chart using addNull for zero values our previous problem was solved. but it take space for that series in each category. If we can trim that space, it can avoid more horizontal panning in chart
See attachment for more
Regards
Shibu
Indus Systems Inc
- Attachments
-
- Picture1.png (98.54 KiB) Viewed 13536 times
Re: Hide Zero Values
Hi Shibu,
Excuse us for the delayed reply.
TeeChart doesn't handle the null points in any way, it just doesn't draw them. If I understand well, you'd like to handle two different situations that can be explained with this snipped of code:
This is what I get as is:
So, the two situations to handle would be:
1. When no series have a visible value for a ValueIndex. In the example above, this happens at ValueIndex 2. You could use an Axis Break tool every time you detect this situation.
2. When there is at least one visible point for a ValueIndex, and at least one not visible: This happens in the example above at ValueIndex 3 and 4. Here, you should calculate the new position and size of the bars manually.
Here you have a first (incomplete) approximation:
Notes:
Take a look at the BarSizeDemo in the features demo program to see how the bars could be moved along the horizontal axis.
You could use the setCustomBarWidth function to set the recalculated bar sizes.
Excuse us for the delayed reply.
TeeChart doesn't handle the null points in any way, it just doesn't draw them. If I understand well, you'd like to handle two different situations that can be explained with this snipped of code:
Code: Select all
tChart1.getAspect().setView3D(false);
for (int i=0; i<3; i++) {
Bar b = new Bar(tChart1.getChart());
b.fillSampleValues();
b.setNull(2);
if (i>0) b.setNull(3);
if (i>1) b.setNull(4);
}
1. When no series have a visible value for a ValueIndex. In the example above, this happens at ValueIndex 2. You could use an Axis Break tool every time you detect this situation.
2. When there is at least one visible point for a ValueIndex, and at least one not visible: This happens in the example above at ValueIndex 3 and 4. Here, you should calculate the new position and size of the bars manually.
Here you have a first (incomplete) approximation:
Code: Select all
int maxCount = 0;
for (int nSeries=0; nSeries<tChart1.getSeriesCount(); nSeries++) {
maxCount = Math.max(maxCount, tChart1.getSeries(nSeries).getCount());
}
axisBreaksTool = new AxisBreaksTool(tChart1.getChart().getAxes().getBottom());
axisBreaksTool.setAxis(tChart1.getAxes().getBottom());
tChart1.getAxes().getBottom().getLabels().getItems().clear();
for (int valueIndex=0; valueIndex<maxCount; valueIndex++) {
int nVisible = 0;
for (int nSeries=0; nSeries<tChart1.getSeriesCount(); nSeries++) {
if (!tChart1.getSeries(nSeries).isNull(valueIndex))
nVisible++;
}
if (nVisible>0) {
double val = tChart1.getSeries(0).getXValues().getValue(valueIndex);
tChart1.getAxes().getBottom().getLabels().getItems().add(val, formatValue(val));
for (int nSeries=0; nSeries<tChart1.getSeriesCount(); nSeries++) {
if (!tChart1.getSeries(nSeries).isNull(valueIndex))
{
//Recalculate bar width and position
}
}
}
else {
double val = tChart1.getSeries(0).getXValues().getValue(valueIndex);
AxisBreak aBreak = new AxisBreak(axisBreaksTool);
aBreak.setEndValue(val+0.5);
aBreak.setStartValue(val-0.5);
aBreak.setStyle(AxisBreakStyle.NONE);
axisBreaksTool.getBreaks().add(aBreak);
}
}
Take a look at the BarSizeDemo in the features demo program to see how the bars could be moved along the horizontal axis.
You could use the setCustomBarWidth function to set the recalculated bar sizes.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |