Chart Export
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Chart Export
When I export the chart, I am getting as attached and not the actual chart, code below
Steema.TeeChart.Export.JPEGFormat jPEG = WebChart2.Chart.Export.Image.JPEG;
jPEG.GrayScale = true;
jPEG.Height = 250;
jPEG.Width = 250;
jPEG.Quality = 100;
jPEG.Save("c:\\chart.jpg");
Steema.TeeChart.Export.JPEGFormat jPEG = WebChart2.Chart.Export.Image.JPEG;
jPEG.GrayScale = true;
jPEG.Height = 250;
jPEG.Width = 250;
jPEG.Quality = 100;
jPEG.Save("c:\\chart.jpg");
- Attachments
-
- chart.jpg (11.47 KiB) Viewed 16025 times
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
I am using session for TempChart is that the problem?
Re: Chart Export
Hello mikethelad,
I hope will helps.
Thanks,
Your code works fine, because the code you attached in previous post, changes the size of image(jpeg) you want export, therefore the chart.jpg have the size are you indicate previously. If you want export the chart with real size you only need export the chart without change the size of image. You can do something as next lines of code:I am using session for TempChart is that the problem?
Code: Select all
ch1 = WebChart1.Chart;
if (Session["ch1"] == null)
{
tmpChart = new System.IO.MemoryStream();
//export Chart to a MemoryStream template
Steema.TeeChart.Export.JPEGFormat jPEG = WebChart1.Chart.Export.Image.JPEG;
jPEG.Save("c:\\chart.jpg");
ch1.Export.Template.Save(tmpChart);
Session.Add("ch1", tmpChart);
}
else
{
//retrieve the session stored Chart
tmpChart = (System.IO.MemoryStream)Session["ch1"];
//set the Stream position to 0 as the last read/write
//will have moved the position to the end of the stream
tmpChart.Position = 0;
//import saved Chart
WebChart1.Chart.Import.Template.Load(tmpChart);
ch1 = WebChart1.Chart;
}
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
Hi, I removed the size settings and this did the same, don't understand the Session["ch1"] or what type this needs to be
Re: Chart Export
Hello mikethelad,
Can you tell us which version are you using? On the other hand, can you please, send a simple code where we can see what are you doing, because we can not reproduce your problem.
Thanks,
Can you tell us which version are you using? On the other hand, can you please, send a simple code where we can see what are you doing, because we can not reproduce your problem.
Session["ch1"] is used when you want retrieve session saved streamed Charts to a WebForm. In this case, you use Session variable with chart name, in main file and next code in GetChart file that allows you achieve it:don't understand the Session["ch1"] or what type this needs to be
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
// *************************************************************
// Code to retrieve Session saved streamed Charts to a WebForm.
// This code should be included if the WebChart 'UseStreams' property is set to True.
// *************************************************************
string chartName = Request.QueryString["Chart"];
if (Session[chartName] != null)
{
System.IO.MemoryStream chartStream = new System.IO.MemoryStream();
chartStream = ((System.IO.MemoryStream)Session[chartName]);
Response.OutputStream.Write(chartStream.ToArray(), 0, (int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
}
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
Hi, am using Steema TeeChart for .NET 2012, I do have muliiple charts on the same page, they all call the same getchart.aspx, is this correct? I have say 40 charts and some are set to invisible all linked to getchart.aspx
Re: Chart Export
Hello mikethelad,
I hope will helps.
Thanks,
You, are in the correct. GetChart class is only the method where you use this to retrieve session saved streamed Charts to a WebForm. The method internally works with variables that allow you check all charts as you have in your asp main.they all call the same getchart.aspx, is this correct? I have say 40 charts and some are set to invisible all linked to getchart.aspx
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
So I assume I could copy this and 40 different versions, to output to different session variables?
Re: Chart Export
Hello mikethelad,
Ok. GetChart is used if you want save the data, made zoom, scroll, but isn't always necessary use it if you want more information about it, I recommend you taking a look in Tutorial 9 - TeeChart and WebChart and ASP.NET to understand best his functionality of GetChart. Moreover you find more examples, in demo asp.
Thanks,
Ok. GetChart is used if you want save the data, made zoom, scroll, but isn't always necessary use it if you want more information about it, I recommend you taking a look in Tutorial 9 - TeeChart and WebChart and ASP.NET to understand best his functionality of GetChart. Moreover you find more examples, in demo asp.
If you want save different variables for each chart, you need you need create one session with 40 variables.So I assume I could copy this and 40 different versions, to output to different session variables?
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
Thanks, makes sense, I have looked at Tutorial 9, my Getchart is slightly different, we have had steema since V1 so guess this has not been updated
Current GetChart.aspx
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
MemoryStream chartStream = new MemoryStream();
chartStream=((MemoryStream)Session[chartName]);
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
Tutorial 9 sample
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
System.IO.MemoryStream chartStream = new System.IO.MemoryStream();
chartStream=((System.IO.MemoryStream)Session[chartName]);
Response.ContentType = "image/" + "png";
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
Does this not store in the session variable of the chart name?
Current GetChart.aspx
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
MemoryStream chartStream = new MemoryStream();
chartStream=((MemoryStream)Session[chartName]);
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
Tutorial 9 sample
string chartName=Request.QueryString["Chart"];
if (Session[chartName]!=null)
{
System.IO.MemoryStream chartStream = new System.IO.MemoryStream();
chartStream=((System.IO.MemoryStream)Session[chartName]);
Response.ContentType = "image/" + "png";
Response.OutputStream.Write(chartStream.ToArray(),0,(int)chartStream.Length);
chartStream.Close();
Session.Remove(chartName);
}
Does this not store in the session variable of the chart name?
Re: Chart Export
Hello mikethelad,
I may not have understood your question correctly.
The TeeCharts (each of the 40 in this case) store as a separate Session object by name of Chart .. redeemable by that name from the Session (ie. Session[chartName]). After retrieval via GetChart the object is removed from the Session (ie. Session.Remove(chartName);)
As, in this case, the tempChart has been saved as JPEG image format ... the retrieved variable will be the JPEG image saved at generation time. The features of that image will depend on the features applied before the Chart is generated (ie. number of Series, their data, their colours, etc). There is no other intelligent information in the Session Object, it is merely an image that will be rendered at the location required in response to the GetChart call (ie. from the Webchart in question on the WebFom page).
If the explanation misses any aspect of your question, please let me know and I'll try to answer it.
I hope will helps.
Thanks,
I may not have understood your question correctly.
The TeeCharts (each of the 40 in this case) store as a separate Session object by name of Chart .. redeemable by that name from the Session (ie. Session[chartName]). After retrieval via GetChart the object is removed from the Session (ie. Session.Remove(chartName);)
As, in this case, the tempChart has been saved as JPEG image format ... the retrieved variable will be the JPEG image saved at generation time. The features of that image will depend on the features applied before the Chart is generated (ie. number of Series, their data, their colours, etc). There is no other intelligent information in the Session Object, it is merely an image that will be rendered at the location required in response to the GetChart call (ie. from the Webchart in question on the WebFom page).
If the explanation misses any aspect of your question, please let me know and I'll try to answer it.
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
All I am trying to do is on an a button save the chart next to the button, so how can I do this?
Re: Chart Export
Hello mikethelad,
Could you please send your project because we can try to find a solution for your problem or suggest you a good solution?
Thanks,
Could you please send your project because we can try to find a solution for your problem or suggest you a good solution?
Thanks,
Best Regards,
Sandra Pazos / 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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
Sorry but the project is massive, so unable to send
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: Chart Export
OK, i made a new project and setup multiple charts one with an export button and all works fine, until I put in the page load
if (Page.IsPostBack) return;
This breaks this, the button causes the page load to be called without this line cuases other system issues
if (Page.IsPostBack) return;
This breaks this, the button causes the page load to be called without this line cuases other system issues