Page 1 of 1
Working with the Marks.Item list
Posted: Sun May 31, 2009 5:49 am
by 9092401
Hi
I have a bar chart and for each bar series I tried to work with the Marks.Item list , but I dont see the marks I defined in the item list.
How exactly am I supposed to work with this .
Thanks.
Posted: Mon Jun 01, 2009 8:47 am
by 10050769
Hello gcrnd,
Please, you could explain exactly that you want do with marks in your application, so we can suggest a solution for your problem.
Thanks,
Posted: Tue Jun 02, 2009 9:18 am
by 9092401
Hi
I have a stacked bar chart and I want a mark on top of each stacked bar with the total . Until now I have used the Mark of the top most series and it worked ok ( bar.Mark.Visible = true) however because of problem that you have with 0 values, I was suggested by Yeray to use a workaround which involved working with the Marks.Items of each series. but I cant seem to see the Marks that are in the Items list . I think I am not working properly with the Marks.Items list and want to know what I should do.
Thanks.
Posted: Tue Jun 02, 2009 9:46 am
by yeray
Hi qcrnd,
I'm still able to understand you. Could you change the following code to reproduce the problem?
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
//create ans populate 4 bar series
for (int i = 0; i < 4; i++)
{
new Bar(tChart1.Chart);
tChart1.Series[i].FillSampleValues(5);
((Bar)tChart1.Series[i]).MultiBar = MultiBars.Stacked;
}
//set some of the series values as 0
tChart1.Series[1].YValues[2] = 0;
tChart1.Series[2].YValues[2] = 0;
tChart1.Series[3].YValues[4] = 0;
tChart1.Series[0].YValues[3] = 0;
//process of setting the 0 values as null to aviod drawing them
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);
}
}
}
//process for show only the last mark on each series
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: Wed Jun 03, 2009 1:33 pm
by 9092401
Hi Yeray
Thanks. The only problem is ... HOW can I set the marks Items text to something else.
tChart1.Series[k].Marks.Items[ValueIndex].Text = MyString doesnt have any effect.
Thanks.
Posted: Wed Jun 03, 2009 2:22 pm
by yeray
Hi qcrnd,
Oh, now I think I understood you. Excuse me.
To change your series marks text you have two options:
- Set your desired text as your series points labels. You could do it when you add the points with the Add() method or you could loop your series and their values to change its labels:
Code: Select all
for (int i = 0; i < tChart1.Series.Count; i++)
{
for (int j = 0; j < tChart1.Series[i].Count; j++)
{
tChart1.Series[i].Labels[j] = "your text";
}
}
- Use OnGetMarkText: You could assign the same method to all the series OnGetMarkText events:
Code: Select all
for (int i = 0; i < tChart1.Series.Count; i++)
{
tChart1.Series[i].GetSeriesMark += new Series.GetSeriesMarkEventHandler(Form1_GetSeriesMark);
}
And then use the event call to change the text to show as you wish:
Code: Select all
void Form1_GetSeriesMark(Series series, GetSeriesMarkEventArgs e)
{
e.MarkText = "Label number " + (e.ValueIndex+1).ToString();
}
Posted: Thu Jun 04, 2009 8:22 am
by 9092401
I Yeray
Thanks. I tried the Labels , and it seems OK Except for one problem which I also saw before in other charts.
Sometimes the Marks , and the Labels on the x Axis get mixed up. for example a label on the x Axis can suddenly change after resize to the same string as the mark , and visa versa.
Is this a defect that you know about.?
Posted: Thu Jun 04, 2009 11:58 am
by yeray
Hi qcrnd,
Could you explain us how could we reproduce it here or could you send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://
www.steema.net/steema.public.attachments newsgroup or at our
upload page.
Thanks in advance.
Posted: Thu Jun 04, 2009 12:24 pm
by 9092401
Hi Yeray
Its not easy to reproduce, it only happens sometimes in our application but I cant send you something so big. I will maybe try later on to build something small and see if it happens.
Thanks.