Show subset of series in bar chart, but all in datatabletool
Show subset of series in bar chart, but all in datatabletool
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi AIDev,
In that case you can using ClickLegend event like this:
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 |
Instructions - How to post in this forum |
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]
Thanks again.[/img]
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).
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
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.
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.
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:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |