Page 1 of 1
pie charts
Posted: Thu Nov 06, 2008 7:23 pm
by 14045174
Save as a template and then load it back (this time I am calling the Chart.Clear() method in between the Save and Load) - not all the Chart 3d options are kept. In fact, Rotation is set back to 360, Elevation - to 315 and Perspective - to 0. Funny think is, if I ever change any of these properties and then do the Save/Load trick - it works. But if I do not touch them when I create the pie - then reloading from template sets different defaults...
Posted: Fri Nov 07, 2008 9:48 am
by narcis
Hi Profitstar,
Values you mention for those properties are default properties. Code below works fine for me here either using commented code or not. Could you please modify it so that we can reproduce the issue here?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private System.IO.MemoryStream stream;
private void InitializeChart()
{
Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
pie1.FillSampleValues();
//tChart1.Aspect.Elevation = 300;
//tChart1.Aspect.Rotation = 300;
//tChart1.Aspect.Perspective = 10;
stream = new System.IO.MemoryStream();
tChart1.Export.Template.Save(stream);
}
private void button1_Click(object sender, EventArgs e)
{
stream.Position = 0;
tChart1.Clear();
tChart1.Import.Template.Load(stream);
}
Thanks in advance.
Posted: Fri Nov 07, 2008 4:24 pm
by 14045174
Your code works because you have your chart object on the form prior to all the template manipulations. There is some magic happening when you do it this way. So try this one:
Code: Select all
private System.IO.MemoryStream stream;
private void InitializeChart()
{
TChart chart = new TChart();
Pie pie = new Pie(chart.Chart);
pie.FillSampleValues();
chart .Aspect.Elevation = 300;
chart .Aspect.Rotation = 300;
chart .Aspect.Perspective = 10;
stream = new System.IO.MemoryStream();
chart .Export.Template.Save(stream);
}
private void button1_Click(object sender, EventArgs e)
{
stream.Position = 0;
tChart1.Clear();
tChart1.Import.Template.Load(stream);
}
This example will demonstrate the way it is used in our system. First, I set up a graph and save it into a template. Close app, go home... Later, I have an option to print a report which is using this graph. At this point I do not have a form do display the graph, all I do is generate output stream with graph in it. Reloading from template in this configuration does not work in your system in a lot of places, since you rely a lot on some drawing events happening in UI, and they are not fired here. Look into my other posts for more problems like this.
Posted: Fri Nov 07, 2008 4:42 pm
by narcis
Hi Profitstar,
Thanks for the information but I'm not able to reproduce the issue here either using the code you posted. Could you please confirm that your project is using latest TeeChart for .NET v3 release available at the client area, which is build 3.5.3225.32183/4/5 from 3rd November 2008?
Thanks in advance.
Posted: Fri Nov 07, 2008 7:50 pm
by 14045174
Try it without setting up the properties:
Code: Select all
private System.IO.MemoryStream stream;
private TChart chart;
private void InitializeChart()
{
TChart chart = new TChart();
Pie pie = new Pie(chart.Chart);
pie.FillSampleValues();
stream = new System.IO.MemoryStream();
chart.Export.Template.Save(stream);
}
// after this point place chart on the form and after clicking on the button compare chart and tChart1
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
pnlGraph.Controls.Add(chart);
chart.Dock = DockStyle.Fill;
stream.Position = 0;
tChart1.Clear();
tChart1.Import.Template.Load(stream);
}
So, this will demonstrate (hopefully) that building the chart "behind the curtains", saving it into a template, and then loading it from the template does not produce the same results.
Posted: Mon Nov 10, 2008 9:43 am
by narcis
Hi Profitstar,
Sorry but I'm still unable to reproduce this here
. I'm using this code:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private System.IO.MemoryStream stream;
private Steema.TeeChart.TChart chart;
private void InitializeChart()
{
chart = new Steema.TeeChart.TChart();
Steema.TeeChart.Styles.Pie pie = new Steema.TeeChart.Styles.Pie(chart.Chart);
pie.FillSampleValues();
stream = new System.IO.MemoryStream();
chart.Export.Template.Save(stream);
}
private void button1_Click(object sender, EventArgs e)
{
this.Controls.Add(chart);
chart.Dock = DockStyle.Fill;
stream.Position = 0;
tChart1.Clear();
tChart1.Import.Template.Load(stream);
//tChart1.Visible = false;
chart.Export.Image.PNG.Save("chart.png");
tChart1.Export.Image.PNG.Save("tChart1.png");
}
Charts on the WinForm and exported images are the same. Could you please confirm this code produces the issue at your end?
Thanks in advance.
Posted: Mon Nov 10, 2008 3:08 pm
by 14045174
Running following code produces 2 different images for me (where tChart1 is placed on the form in the designer):
Code: Select all
var chart = new TChart();
var pie = new Pie(chart.Chart);
pie.FillSampleValues();
var stream = new MemoryStream();
chart.Export.Template.Save(stream);
stream.Position = 0;
tChart1.Clear();
tChart1.Import.Template.Load(stream);
chart.Export.Image.PNG.Save("chart.png");
tChart1.Export.Image.PNG.Save("tChart1.png");
The difference in the chart objects:
- chart
- Orthogonal = true
- Rotation = 345
- Elevation = 345
- Perspective = 15
- tChart1
- Orthogonal = false
- Rotation = 360
- Elevation = 315
- Perspective = 0
Posted: Mon Nov 10, 2008 4:04 pm
by narcis
Hi Profitstar,
tChart1 has same settings you mention for chart here. Could you please confirm the exact TeeChart build number you are using and I'll send you an exe compiled here so that you can try using it next to the TeeChart assembly you are using?
Thanks in advance.
Posted: Mon Nov 10, 2008 6:50 pm
by 14045174
I am using the Nov 3rd release.
Posted: Tue Nov 11, 2008 8:55 am
by narcis
Hi Profitstar,
And in which Visual Studio version are you using it? It is important for the build number as it's different for each IDE build.
Thanks in advance.
Posted: Thu Nov 13, 2008 2:48 pm
by 14045174
I am using VS8, but since middle of yesterday I cannot reproduce it either... Strange...
Posted: Thu Nov 13, 2008 3:04 pm
by narcis
Hi Profitstar,
It could be that your project references or
AssemblyFolders in your machine hadn't been correctly updated until yesterday.
If you can reproduce the issue again please let us know and we will send you the .exe built here.
Thanks in advance.