Show subset of series in bar chart, but all in datatabletool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
AIDev
Newbie
Newbie
Posts: 22
Joined: Wed May 23, 2007 12:00 am

Show subset of series in bar chart, but all in datatabletool

Post by AIDev » Tue Mar 31, 2009 6:13 pm

I am using the data table tool with a standard bar chart with 8 series. The series are visible by selecting checkboxes in the legend. I would like to be able to limit the bar chart to show a max of 2 series in the bar chart, while still showing all 8 series in the data table. Is this possible?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 01, 2009 7:02 am

Hi AIDev,

In that case you can using ClickLegend event like this:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      for (int i = 0; i < 8; i++)
      {
        tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
        tChart1[i].FillSampleValues();
      }

      Steema.TeeChart.Tools.DataTableTool dataTable1 = new Steema.TeeChart.Tools.DataTableTool(tChart1.Chart);

      tChart1.Legend.CheckBoxes = true;

      tChart1.ClickLegend += new MouseEventHandler(tChart1_ClickLegend);
    }

    void tChart1_ClickLegend(object sender, MouseEventArgs e)
    {
      int index = tChart1.Legend.Clicked(e.X, e.Y);

      tChart1[index].Active = true;
      if (tChart1[index].Color == Color.Transparent)
      {
        tChart1[index].Color = Steema.TeeChart.Themes.OperaTheme.OperaPalette[index];
      }
      else
      {
        tChart1[index].Color = Color.Transparent;
      }
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

AIDev
Newbie
Newbie
Posts: 22
Joined: Wed May 23, 2007 12:00 am

Post by AIDev » Wed Apr 01, 2009 4:41 pm

This works pretty well. Is there a way to shrink the width of the transparent bars, so the visible bars (with transparent bars in between) are directly adjacent? This would make the chart a little clearer to view. For instance, if series 1 and 4 were checked, it would be nice to have series 1 and 4 bars right next to eachother and centered...

Thanks again.[/img]

AIDev
Newbie
Newbie
Posts: 22
Joined: Wed May 23, 2007 12:00 am

Post by AIDev » Wed Apr 01, 2009 5:48 pm

One other question: The checkbox remains checked with the method above. I cannot find a way to show it as being unchecked when the series is transparent - is there a way to do this?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu Apr 02, 2009 8:18 am

Hi AIDev,

I'm afraid that dataTable tool wasn't thought to be as customizable as you need to achieve this. Maybe it would be a good idea to allow direct access to this tool's items to customize them, something like the legend.

I've added it to the wish list to be implemented in future releases (TF02014048).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

AIDev
Newbie
Newbie
Posts: 22
Joined: Wed May 23, 2007 12:00 am

Post by AIDev » Thu Apr 02, 2009 11:40 pm

Hi Yeray,

I think I can get around the bar positioning, but the checkbox still displaying is an issue - I think this would be very confusing to the customer. You mention that the legend is more customizable - is there a way I might be able to customize it so that the check does not show when "deselected" using the method responding to the ClickLegend event?

Thanks again.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Fri Apr 03, 2009 11:30 am

Hi AIDev,

The legend checkboxes are shown as checked or unchecked automatically depending on if the according series is active or not. So I'm afraid that this is not customizable. But you always can draw a white square over the checkboxes that you want. Here is the code:

Code: Select all

int CheckBoxesLeftOffset, CheckBoxesTopOffset, CheckBoxesSize, CheckBoxesSeparation;

private void InitializeChart()
{
//...
    CheckBoxesLeftOffset = 6;
    CheckBoxesTopOffset = 5;
    CheckBoxesSize = 10;
    CheckBoxesSeparation = 17;
//...
    tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
}

void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
    tChart1.Graphics3D.Pen.Visible = false;
            
    for (int i = 0; i < tChart1.Series.Count; i++)
    {
        if (tChart1[i].Color == Color.Transparent)
        {
            tChart1.Graphics3D.Rectangle(tChart1.Legend.Left + CheckBoxesLeftOffset, tChart1.Legend.Top + CheckBoxesTopOffset + (CheckBoxesSeparation*i), tChart1.Legend.Left + CheckBoxesLeftOffset + CheckBoxesSize, tChart1.Legend.Top + CheckBoxesTopOffset + CheckBoxesSize + (CheckBoxesSeparation*i));
        }
    }
}
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply