Page 1 of 1
Show subset of series in bar chart, but all in datatabletool
Posted: Tue Mar 31, 2009 6:13 pm
by 13045294
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?
Posted: Wed Apr 01, 2009 7:02 am
by narcis
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;
}
}
Posted: Wed Apr 01, 2009 4:41 pm
by 13045294
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]
Posted: Wed Apr 01, 2009 5:48 pm
by 13045294
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?
Posted: Thu Apr 02, 2009 8:18 am
by yeray
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).
Posted: Thu Apr 02, 2009 11:40 pm
by 13045294
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.
Posted: Fri Apr 03, 2009 11:30 am
by yeray
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));
}
}
}