Page 1 of 1

Webchart Export

Posted: Wed Nov 17, 2010 7:10 pm
by 9639571
Can someone please tell me how to have the annotations move with the chart when the chart is resized?

If I do not specify a size of the image, the image is created at a width of 632 and a height of 456, and the annotations are correct.

If I specify a size of a width of 800 and a height of 577, the chart gets rezised but the Annotations do not move with the chart.


WebChart1.Chart.Series.Add(LineBar1)
WebChart1.Chart.Export.Image.PNG.Height = 577.2
WebChart1.Chart.Export.Image.PNG.Width = 800
WebChart1.Chart.Export.Image.PNG.Save("c:\DRMetric.png")

I am certain that the problem lie with me spefifying the annotation positons, such as
Annotation1.Left = 10
Annotation1.Top = 390
Annotation1.Text = "ASSUMPTIONS:"

Is there a way to reference the annotations from the bottom? If so, that would work. My Annotations are on the bottom left and right of the chart.

Is there a way to export a larger graphic and have the annotation move with the chart?

Re: Webchart Export

Posted: Thu Nov 18, 2010 12:56 pm
by 10050769
Hello phil1995,

I have made a simple code for your. Please check if next code works as you want:

Code: Select all

    Steema.TeeChart.Chart ch1;
    protected void Page_Load(object sender, EventArgs e)
    {
        ch1 = WebChart1.Chart;
  
        Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(ch1);
        Steema.TeeChart.Tools.Annotation an = new Steema.TeeChart.Tools.Annotation(ch1);
      
            ch1.Aspect.View3D = false;
            bar1.FillSampleValues();
            ch1.Panel.Gradient.Visible = false;
            ch1.Walls.Visible = false;
            bar1.FillSampleValues();
            System.Drawing.Bitmap bmp = ch1.Bitmap(800, 577);           
        
            an.Shape.CustomPosition=true;
            an.Left = 10;
            an.Top = 90;
            an.Text = "ASSUMPTIONS:";
   
            bmp = ch1.Bitmap(800,577);
            string filename = "c:\\DRMetric.png";
            System.IO.FileStream imageStream = new System.IO.FileStream(filename, System.IO.FileMode.Create);
            ch1.Export.Image.PNG.Save(imageStream, bmp, bmp.Width, bmp.Height);
            imageStream.Close();
    }
If previous code doesn't work fine for you please let me know.

I hope will helps.

Thanks,

Re: Webchart Export

Posted: Thu Nov 18, 2010 2:00 pm
by 9639571
Thanks for that. I still do not understand how this answers my original question.

The problem I am having , is that I am rendering the graphic on the web at one resolution, and then scaling up the graphic when I export it. When I scale up the graphic, the code does not scale the hard coded coordinates of the annotation with it. This leaves the annotations in the middle of the chart.

What I need is a way to scale those positions accordingly, or a way to reference the coordinates from the bottom instead of the top. Since my annotations are in the bottom corners, a reference from the bottom would work no matter what the scale.

If I were to move the annotations to the top, they should work, but that is not the charting format we use.

This doesnt seem like it should be that difficult, as the titles and axes all scale with the chart.

Re: Webchart Export

Posted: Thu Nov 18, 2010 3:33 pm
by 10050769
Hello phil1995,

Sorry I think that I had not understood exactly what are you want. For do what are you want you need relative positions that you can calculate it, using methods that give TeeChart for example: CalcYPosValue, CalcXPosValue, CalcPosValue etc. You can use these methods as do in next example of code:

Code: Select all

Steema.TeeChart.Chart ch1;
    protected void Page_Load(object sender, EventArgs e)
    {
        ch1 = WebChart1.Chart;

        Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(ch1);
        Steema.TeeChart.Tools.Annotation an = new Steema.TeeChart.Tools.Annotation(ch1);

        ch1.Aspect.View3D = false;
        bar1.FillSampleValues();
        ch1.Panel.Gradient.Visible = false;
        ch1.Walls.Visible = false;
        bar1.FillSampleValues();
        System.Drawing.Bitmap bmp = ch1.Bitmap();

        an.Shape.CustomPosition = true;
        an.Left = WebChart1.Chart.Axes.Left.CalcYPosValue(10);
        an.Top = WebChart1.Chart.Axes.Top.CalcXPosValue(15);
     
        an.Text = "ASSUMPTIONS:";
        bmp = ch1.Bitmap(); 
        WebChart1.Chart.Export.Image.PNG.Height = 577;
        WebChart1.Chart.Export.Image.PNG.Width = 800;
        WebChart1.Chart.Export.Image.PNG.Save("c:\\DRMetric.png");
        
    }
Could you please, tell us if previous code works as you want? If it doesn't work fine for you, please explain exactly what are you want, so we try to find a good solution for you.

I hope will helps.

Thanks