Page 1 of 1
Artifacts in stacked bar with series values zero
Posted: Wed May 13, 2009 11:39 am
by 9092401
Hi
I have a stacked bar with series that have a white pen width 2 and sometimes the value on the x axis can be zero. The problem I found is that in this case you still draw the series with a few pixels and it doesnt look nice.
See the image . For example in the second bar and forth bar . The last series (orange Reopen ) is drawn on top even though its value is 0 and it doesnt look nice. You will see other examples in between other series as well for example the one under bottom axis label called "sa"
HOw can I remove these artifacts.
Thanks.
Posted: Wed May 13, 2009 3:21 pm
by yeray
Hi qcrnd,
Yes, you are right. Note that this only happens in 2D charts. I've added it to the wish list to be fixed in future releases (TF02014154).
A workarround is to look for the 0 values and set them as null:
Code: Select all
for (int i = 0; i < tChart1.Series.Count; i++)
{
for (int j = 0; j < tChart1.Series[i].Count; j++)
{
if (tChart1.Series[i].YValues[j] == 0)
{
tChart1.Series[i].SetNull(j);
}
}
}
Posted: Sun May 17, 2009 5:45 am
by 9092401
Hi Yeray
Thanks for the reply.
Your workaround is OK but it causes a new problem. In the stacked bar we set the last series (the top most series) Marks.Visible to true so that we can have a mark above each stacked bar.
Because of your workaround , if the value of the top series is 0 and we set the value to Null, then the mark is not visible. The Mark is only visible in bars that the top series YValue is > 0.
How can I solve this issue as well.
Thanks
Posted: Mon May 18, 2009 11:09 am
by yeray
Hi qcrnd,
I'm afraid that in then you should set each mark to be hidden or shown individually. For example, to show the last non null values:
Code: Select all
tChart1.Aspect.View3D = false;
for (int i = 0; i < 4; i++)
{
new Bar(tChart1.Chart);
tChart1.Series[i].FillSampleValues(5);
((Bar)tChart1.Series[i]).MultiBar = MultiBars.Stacked;
}
tChart1.Series[1].YValues[2] = 0;
tChart1.Series[2].YValues[2] = 0;
tChart1.Series[3].YValues[4] = 0;
tChart1.Series[0].YValues[3] = 0;
for (int i = 0; i < tChart1.Series.Count; i++)
{
for (int j = 0; j < tChart1.Series[i].Count; j++)
{
if (tChart1.Series[i].YValues[j] == 0)
{
tChart1.Series[i].SetNull(j);
}
}
}
for (int ValueIndex = 0; ValueIndex < tChart1.Series[0].Count; ValueIndex++)
{
int SeriesIndex = tChart1.Series.Count-1;
while ((SeriesIndex > 0) && (tChart1.Series[SeriesIndex].IsNull(ValueIndex)))
{
SeriesIndex--;
}
for (int k = 0; k < tChart1.Series.Count; k++)
{
tChart1.Series[k].Marks.Items[ValueIndex].Visible = k == SeriesIndex;
}
}
Posted: Mon May 18, 2009 12:49 pm
by 9092401
Hi
It doesnt seem to work . I dont see any marks.
I do have another workaround that uses GetSeriesMark and decides which marks to draw and which not But I think your workaround looks better so I would like to see how to make it work.
It seems that Marks Items doesnt have any effect on my graph.
I have a feeling that there is something more missing
Thanks.
Posted: Mon May 18, 2009 1:22 pm
by yeray
Hi qcrnd,
It's strange, have you tested the code I said above in a new project with a new chart?
Posted: Mon May 18, 2009 1:58 pm
by 9092401
NO I tried in my application.
In anycase I think I will remain with my workaround and wait till it gets fixed properly.
When do you reckon it will be fixed ?
Thank.s
Posted: Mon May 18, 2009 2:30 pm
by yeray
Hi qcrnd,
I can't tell you a date. I recommend you to be aware at this forum or subscribe to our
RSS news feed for new release announcements and what's fixed on them.