Page 1 of 1
Changing Legend Symbol Width in Code?
Posted: Tue Oct 19, 2010 1:06 pm
by 13050364
Hi folks
I can change this setting from the Chart Editor by clicking the Legend tab, then the Symbols tab, then modifying the Width text box
Ive tried doing the following in code:
myChart.Legend.Symbol.Width = 5;
myChart.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;
However the legend symbol width is not changed. Can I do this from code?
Re: Changing Legend Symbol Width in Code?
Posted: Tue Oct 19, 2010 2:32 pm
by 10050769
Hello Dave,
I have made a simple code that increase an decrease width of legend symbols:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.FillSampleValues(5);
}
private void button1_Click(object sender, EventArgs e)
{
tChart1.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;
tChart1.Legend.Symbol.Width = tChart1.Legend.Symbol.Width+5;
}
private void button2_Click(object sender, EventArgs e)
{
tChart1.Legend.Symbol.WidthUnits = Steema.TeeChart.LegendSymbolSize.Pixels;
tChart1.Legend.Symbol.Width = tChart1.Legend.Symbol.Width - 5;
}
Could you please, tell us if this code works for you? Moreover, could you say what version of TeeChart.Net are you using?
I hope will helps.
Thanks,
Re: Changing Legend Symbol Width in Code?
Posted: Wed Oct 20, 2010 8:02 am
by 13050364
Sandra
Thanks that works. Ive discovered I need to set the symbol width AFTER adding a series to the chart.
Re: Changing Legend Symbol Width in Code?
Posted: Wed Oct 20, 2010 8:36 am
by 10050769
Hello Dave,
I am glad that solution works for you
.
Thanks,