Page 1 of 1
Changing series type
Posted: Fri Nov 21, 2008 9:02 pm
by 14045174
I have a bar chart and gradient is visible for my bar series. Later I decide to change the type from bar to pie... All the slices of my new pie are the same color and there is no way to change this, unless I change it back to be a bar series, make gradient invisible and change it again to pie. Again, this is my users, who will do this type of changes and I am afraid, I cannot expect them to accept this kind of work around.
Posted: Mon Nov 24, 2008 9:32 am
by narcis
Hi Profitstar,
In that case you should do something like this:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.FillSampleValues();
bar1.Gradient.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
tChart1[0].ColorEach = true;
if (tChart1[0] is Steema.TeeChart.Styles.Bar)
{
(tChart1[0] as Steema.TeeChart.Styles.Bar).Gradient.Visible = false;
}
Steema.TeeChart.Styles.Series s = tChart1[0];
Steema.TeeChart.Styles.Series.ChangeType(ref s, typeof(Steema.TeeChart.Styles.Pie));
}
If you don't want to have to reset default series setting you can create a new Pie series, assign Bar series as its datasource and then remove Bar series, for example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.FillSampleValues();
bar1.Gradient.Visible = true;
}
private void button1_Click(object sender, EventArgs e)
{
Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
pie1.DataSource = tChart1[0];
tChart1.Series.Remove(tChart1[0]);
}
Posted: Tue Nov 25, 2008 3:51 pm
by 14045174
Well, again, it is not me, who will make the change. The problem is a lot bigger, then just switching from bar to a pie. Same problem exists with any series with gradient (wherever that series has gradient) on. Also, some series, like bars, have other default behaviors (like setting axis offsets). When switching from bar to area (which by default does not set the offset on axis) the offset is not reset. Again, my users expect it to work, and they do not want to learn all the workarounds in TChart, they just have other things to do. From other side, I have no idea, what else is left out, when I simply change the series type. Your editor is less than usable for busy people, who want to have a graph on their report, but do not want to spend the whole day setting it up. So, we have limited, what they can change on the graph without going into the editor (in most cases), but this means, that some of the options are just not available for them, so fixing some of the settings on their side is impossible. In the case of changing series type, I just do not have all the information, what are the defaults for different series types and in any case, you want me to write the code, which really has to exist in the TChart's series type change event and you guys are the ones, who really know what needs to happen there.
Posted: Tue Nov 25, 2008 4:34 pm
by narcis
Hi UserLS,
Ok, I have added a feature request to the wish-list which consists on implementing an option to reset series to new series style default values when changing series type.