Selecting a series to chart
Selecting a series to chart
I have 4 series that I am currently charting on a single line chart but since they vary in scale greatly the lines are nearly flat and are of little to no use. I would like to allow the user to select which series to chart and have the option to select all. I am wondering if there is a way to use hotspots or something to handle this within the chart, possibly in the legend. The other option is to remove the legend and handle it with a legend that I create in HTML to control the selection of series.
Any suggestions?
Any suggestions?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi chiphotx,
The easiest way to achieve that is using legend checkboxes:
The easiest way to achieve that is using legend checkboxes:
Code: Select all
tChart1.Legend.CheckBoxes = true;
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 |
I've got this code to handle the code but it doesn't catch the event.
Private Sub WebChart1_ClickLegend(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles WebChart1.ClickLegend
Dim SeriesIndex As Integer
SeriesIndex = WebChart1.Chart.Legend.Clicked(e.X, e.Y)
test.Text = "helo"
End Sub
Private Sub WebChart1_ClickLegend(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles WebChart1.ClickLegend
Dim SeriesIndex As Integer
SeriesIndex = WebChart1.Chart.Legend.Clicked(e.X, e.Y)
test.Text = "helo"
End Sub
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi chiphotx,
In an ASP.NET application you can use legend checkboxes doing something like this:
You can convert C# code to VB.NET using one of the language conversors below:
http://carlosag.net/Tools/CodeTranslator/Default.aspx
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
In an ASP.NET application you can use legend checkboxes doing something like this:
Code: Select all
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
namespace LegendCheckboxes
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected Steema.TeeChart.Web.WebChart WebChart1;
public static MemoryStream tmpChart;
private static int index = -1;
private static bool flag=true;
private static ArrayList checkedSeries;
private void Page_Load(object sender, System.EventArgs e)
{
Steema.TeeChart.Chart ch1;
if(flag)
{
ch1=WebChart1.Chart;
ch1.Legend.CheckBoxes = true;
ch1.Series.Add(new Steema.TeeChart.Styles.Line());
ch1.Series.Add(new Steema.TeeChart.Styles.Line());
ch1.Series.Add(new Steema.TeeChart.Styles.Line());
ch1.Series.Add(new Steema.TeeChart.Styles.Line());
checkedSeries = new ArrayList();
for (int i=0;i<ch1.Series.Count;++i)
{
ch1[i].FillSampleValues();
CheckedSeries chk = new CheckedSeries(ch1[i].Active, i);
checkedSeries.Add(chk);
}
tmpChart = new MemoryStream();
ch1.Export.Template.Save(tmpChart);
flag = false;
}
else
{
ch1=WebChart1.Chart;
tmpChart.Position = 0;
ch1.Import.Template.Load(tmpChart);
}
}
private void WebChart1_ClickLegend(object sender, System.Web.UI.ImageClickEventArgs e)
{
index=WebChart1.Chart.Legend.Clicked(e.X,e.Y);
if(index != -1)
{
CheckedSeries chk = (CheckedSeries)checkedSeries[index];
chk.IsActive = !chk.IsActive;
checkedSeries.RemoveAt(chk.Index);
checkedSeries.Insert(chk.Index,chk);
Bitmap bmp = WebChart1.Chart.Bitmap();
}
}
private void WebChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
for (int i=0;i<WebChart1.Chart.Series.Count;++i)
{
CheckedSeries chk = (CheckedSeries)checkedSeries[i];
WebChart1.Chart[i].Active = chk.IsActive;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.WebChart1.ClickLegend += new Steema.TeeChart.Web.WebChart.ClickEventHandler(this.WebChart1_ClickLegend);
this.WebChart1.BeforeDraw += new Steema.TeeChart.PaintChartEventHandler(this.WebChart1_BeforeDraw);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public struct CheckedSeries
{
public CheckedSeries(bool isActive, int index)
{
IsActive = isActive;
Index = index;
}
public bool IsActive;
public int Index;
}
}
}
http://carlosag.net/Tools/CodeTranslator/Default.aspx
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
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 |
ClickLegend
Hi Narcís,
I have tried your code but I was getting a cross (X) image box when run.
Could you please send me a complete workable source code?
I am having difficulty to enable the "click legend".
Thanks.
I have tried your code but I was getting a cross (X) image box when run.
Could you please send me a complete workable source code?
I am having difficulty to enable the "click legend".
Thanks.
ClickLegend
Hi Narcís,
I am able to get it to work now.
But there is an issue (I think I have posted it before) whereby when click on legend checkbox, hold down and release of the mouse click is considered "2 clicks".
Is this bug has been resolved?
If yes, where do I get the patch?
If not, when do we expect a solution?
Thanks.
I am able to get it to work now.
But there is an issue (I think I have posted it before) whereby when click on legend checkbox, hold down and release of the mouse click is considered "2 clicks".
Is this bug has been resolved?
If yes, where do I get the patch?
If not, when do we expect a solution?
Thanks.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi tangone,
Thanks in advance.
Yes, you posted this here.But there is an issue (I think I have posted it before) whereby when click on legend checkbox, hold down and release of the mouse click is considered "2 clicks".
No, this issue hasn't been fixed yet.Is this bug has been resolved?
All TeeChart maintenance releases can be downloaded at the client area.If yes, where do I get the patch?
I'm sorry but I can't give an estimate date at the moment. For new release announcements and what's being fixed on them please be aware at this forum or subscribe to our RSS feed.If not, when do we expect a solution?
Thanks in advance.
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 |