Chart Export

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Chart Export

Post by mikethelad » Mon Dec 17, 2012 4:37 pm

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");
Attachments
chart.jpg
chart.jpg (11.47 KiB) Viewed 16143 times

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Mon Dec 17, 2012 5:25 pm

I am using session for TempChart is that the problem?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Tue Dec 18, 2012 10:46 am

Hello mikethelad,
I am using session for TempChart is that the problem?
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:

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;
        }
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
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Tue Dec 18, 2012 11:01 am

Hi, I removed the size settings and this did the same, don't understand the Session["ch1"] or what type this needs to be

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Tue Dec 18, 2012 12:24 pm

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.
don't understand the Session["ch1"] or what type this needs to be
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:

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);
        }
    }
Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Tue Dec 18, 2012 3:37 pm

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

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Wed Dec 19, 2012 9:20 am

Hello mikethelad,
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
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.

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
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Wed Dec 19, 2012 9:46 am

So I assume I could copy this and 40 different versions, to output to different session variables?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Wed Dec 19, 2012 12:02 pm

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.
So I assume I could copy this and 40 different versions, to output to different session variables?
If you want save different variables for each chart, you need you need create one session with 40 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
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Wed Dec 19, 2012 12:16 pm

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?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Wed Dec 19, 2012 12:58 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Wed Dec 19, 2012 1:33 pm

All I am trying to do is on an a button save the chart next to the button, so how can I do this?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Chart Export

Post by Sandra » Wed Dec 19, 2012 3:07 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Wed Dec 19, 2012 3:08 pm

Sorry but the project is massive, so unable to send

mikethelad
Newbie
Newbie
Posts: 58
Joined: Thu Jul 05, 2012 12:00 am

Re: Chart Export

Post by mikethelad » Wed Dec 19, 2012 4:17 pm

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

Post Reply