Page 1 of 1

WebChart Zooming - Custom Axis

Posted: Thu Oct 12, 2006 1:32 pm
by 9790349
Hi,

I have a problem with getting the Minimum and Maximum from WebChart Custom Axes using TeeChart for .NET [06 OCT 2006] RELEASE 2.0.2469.25744/5.

To demonstrate my problem I sent a message to news://www.steema.net/steema.public.attachments

Best regards,

Gabor Varga

Posted: Fri Oct 13, 2006 2:15 pm
by narcis
Hi Gabor,

To zoom with custom axes you need to do something as shown in this FAQs item.

If the problem persists please send us an example we can run "as-is" to reproduce the problem here. As with your code snippet we can't see its context in the application.

Posted: Mon Feb 12, 2007 2:16 pm
by 9790349
Hi,

I uploaded a sample ASP.NET Web Application to demonstrate the problem.

(http://www.steema.net/upload/ WebFormSample.zip, Length 1236361)

After starting the application click on the Button labeled "Get Axis minimum, maximum".

Best regards,

Gabor Varga

Posted: Mon Feb 12, 2007 5:00 pm
by narcis
Hi Gabor,

Thanks for the example, we will study the code and get back to you ASAP.

Posted: Wed Feb 21, 2007 9:15 am
by 9790349
Hi,

May I ask you that could you reproduce the issue?

Best regards,

Gabor Varga

Posted: Wed Feb 21, 2007 9:20 am
by narcis
Hi Gabor,

Yes, we could reproduce the issue but we are still investigating it. We will get back to you when we have further news.

Posted: Mon Mar 12, 2007 9:21 am
by 9790349
Hi,

Some additional information for this issue:

If you add a ZoomTool to the Chart you will get correct Minimum and Maximum values when the Chart is zoomed.

Is it possible to force to be in zoomed state from my code? It would be an acceptable temporary workaround for me.

Best regards,

Gabor Varga

Posted: Mon Mar 12, 2007 4:27 pm
by narcis
Hi Gabor,

We found that a workaround could be using this:

Code: Select all

  bmp := ch1.Bitmap();
  ((ZoomTool(ch1.Tools[0])).Zoom(ch1.ChartRect));
The code above forces the chart being drawn and then zooms it as if the zoomed area was the entire chart. So the full example could be like this:

Code: Select all

unit WebForm1;

interface

uses
  System.Collections, System.ComponentModel,
  System.Data, System.Drawing, System.Web, System.Web.SessionState,
  System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls, 
  Steema.TeeChart.Web, Borland.VCL.SysUtils, Steema.TeeChart.Styles,
  Steema.TeeChart, System.IO, Steema.TeeChart.Tools;

type
  TWebForm1 = class(System.Web.UI.Page)
  {$REGION 'Designer Managed Code'}
  strict private
    procedure InitializeComponent;
    procedure Button1_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict private
    procedure Page_Load(sender: System.Object; e: System.EventArgs);
  strict protected
    WebChart1: Steema.TeeChart.Web.WebChart;
    Button1: System.Web.UI.WebControls.Button;
    Label1: System.Web.UI.WebControls.Label;
    Label2: System.Web.UI.WebControls.Label;
    procedure OnInit(e: EventArgs); override;
  private
    { Private Declarations }
    procedure CheckZoom(wChart: WebChart);
    procedure UpdateLabels;
  public
    { Public Declarations }
  end;

implementation

{$REGION 'Designer Managed Code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>

procedure TWebForm1.InitializeComponent;
begin
  Include(Self.Button1.Click, Self.Button1_Click);
  Include(Self.Load, Self.Page_Load);
end;
{$ENDREGION}

procedure TWebForm1.Page_Load(sender: System.Object; e: System.EventArgs);
var
  line1: Line;
  ch1 : Steema.TeeChart.Chart;
  tmpChart : MemoryStream;
  bmp: Bitmap;
begin
  ch1 := WebChart1.Chart;


 if (Session['ch1'] = nil) then
  begin
    line1 := Line.Create;
    ch1.Series.Add(line1);
    line1.FillSampleValues;

    tmpChart := MemoryStream.Create;
    //export Chart to a MemoryStream template
    ch1.Export.Template.Save(tmpChart);

    Session['ch1'] := tmpChart;
  end
  else
  begin
    //retrieve the session stored Chart
    tmpChart := 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
    ch1.Import.Template.Load(tmpChart);
  end;

  CheckZoom(WebChart1);

  //Workaround to force axes having valid values
  bmp := ch1.Bitmap();
  ((ZoomTool(ch1.Tools[0])).Zoom(ch1.ChartRect));

  UpdateLabels;
end;

procedure TWebForm1.CheckZoom(wChart: WebChart);
var zoomedState: ArrayList;
begin
  zoomedState := (ArrayList(Session[(wChart.ID + 'Zoomed')]));
  zoomedState := (ZoomTool(wChart.Chart.Tools[0])).SetCurrentZoom(Request,
      zoomedState);
  if (zoomedState = nil) then
    Session.Remove((wChart.ID + 'Zoomed'))
  else
    Session.Add((wChart.ID + 'Zoomed'), zoomedState);
end;

procedure TWebForm1.UpdateLabels;
begin
  Label1.Text := WebChart1.Chart.Axes.Left.Minimum.ToString;
  Label2.Text := WebChart1.Chart.Axes.Left.Maximum.ToString;
end;

procedure TWebForm1.OnInit(e: EventArgs);
var zoomTool1: Steema.TeeChart.Tools.ZoomTool;
begin
  //
  // Required for Designer support
  //
  InitializeComponent;
  zoomTool1:=ZoomTool.Create(WebChart1.Chart);

  inherited OnInit(e);
end;

procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
  UpdateLabels;
end;

end.