Hi, I have a chart with 4 series that represents 2 different types of data (ie. both data values have a Line series and an Area series that display the same x,y coordinates):
Since I do not need to display both the Following Error LINE and Following Error AREA series, I would like to automatically uncheck one when the other is checked. Is this possible? I thought about handling a "Series Visible" event and just unchecking the other series inside this event.
Thanks,
Kevin
Need event to fire when series visibility changes
Re: Need event to fire when series visibility changes
Hello Kevin,
I have made a simple code when you unchecked or checked checkbox of Legend, disable the series in my case of same type and I recommend you do something us next code:
Could you please, confirm us if previous code works as you expected?
I hope will helps.
Thank,
I have made a simple code when you unchecked or checked checkbox of Legend, disable the series in my case of same type and I recommend you do something us next code:
Code: Select all
public Form1()
{
InitializeComponent();
tChart1.Aspect.View3D = false;
InitializeChart();
}
int index = 1;
private void InitializeChart()
{
Steema.TeeChart.Styles.Line line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
Steema.TeeChart.Styles.Area area = new Steema.TeeChart.Styles.Area(tChart1.Chart);
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
Steema.TeeChart.Styles.Area area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
line.FillSampleValues();
line1.FillSampleValues();
area.DataSource = line;
area1.DataSource = line1;
area.Color = Color.Transparent;
area.AreaLines.Visible = false;
area.Stairs = true;
area1.Color = Color.Transparent;
area1.AreaLines.Visible = false;
area1.Stairs = true;
tChart1.Legend.CheckBoxes = true;
tChart1.ClickLegend += new MouseEventHandler(tChart1_ClickLegend);
}
void tChart1_ClickLegend(object sender, MouseEventArgs e)
{
if(index==1)
{
//Lines
if(!tChart1[0].Visible && tChart1[2].Visible)
{
tChart1[2].Visible=false;
}
else if(!tChart1[2].Visible && tChart1[0].Visible)
{
tChart1[0].Visible=false;
}
//Areas
if (!tChart1[1].Visible && tChart1[3].Visible)
{
tChart1[3].Visible = false;
}
else if (!tChart1[3].Visible && tChart1[1].Visible)
{
tChart1[1].Visible = false;
}
index++;//IndexControlClicks
}
else
{
//Lines
if(!tChart1[0].Visible && tChart1[2].Visible)
{
tChart1[0].Visible=true;
}
else if(!tChart1[2].Visible && tChart1[0].Visible)
{
tChart1[2].Visible=true;
}
//Areas
if (!tChart1[1].Visible && tChart1[3].Visible)
{
tChart1[1].Visible = true;
}
else if (!tChart1[3].Visible && tChart1[1].Visible)
{
tChart1[3].Visible = true;
}
index = 1;//IndexControll clicks
}
I hope will helps.
Thank,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Need event to fire when series visibility changes
Thanks. I tested the code and it worked okay however it did not allow me to make the series visible after clicking them off. This is not a problem though because I worked from your code and made mine work. The biggest thing was learning about the ClickLegend event.
Next question: Is it possible to know what item the user clicks within the Legend? Currently, I just toggle between Area and Line for all Series, but I would love to be able to only toggle the group of similar series that the user clicks on.
Thanks
Next question: Is it possible to know what item the user clicks within the Legend? Currently, I just toggle between Area and Line for all Series, but I would love to be able to only toggle the group of similar series that the user clicks on.
Thanks
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Need event to fire when series visibility changes
Hi LibDundas,
To identify series types you might be interested in the example I posted here.
Hope this helps!
Yes, this possible using Legend's Clicked method as in the example Yeray posted here.Next question: Is it possible to know what item the user clicks within the Legend? Currently, I just toggle between Area and Line for all Series, but I would love to be able to only toggle the group of similar series that the user clicks on.
To identify series types you might be interested in the example I posted here.
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Need event to fire when series visibility changes
Hi Narcís, that worked perfectly.
Thank you very much!
Thank you very much!