Page 1 of 1
Unzoom
Posted: Tue Apr 21, 2015 8:12 am
by 15669761
I am using 'Steema TeeChart for .NET 2015 4.1.2015.03110\net40\x86\TeeChart.dll'
I'm trying to unzoom programmatically using Chart.Zoom.Undo(); but it won't work.
I also tried using the ZoomTool which is added to the chart but none of my approaches led
to the desired result,
any advice?
Re: Unzoom
Posted: Tue Apr 21, 2015 9:02 am
by Christopher
Will wrote:
I'm trying to unzoom programmatically using Chart.Zoom.Undo(); but it won't work.
I also tried using the ZoomTool which is added to the chart but none of my approaches led
to the desired result,
Using the same TeeChart.dll and the following code:
Code: Select all
Line series1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Visible = false;
series1 = new Line(tChart1.Chart);
series1.FillSampleValues();
}
private void button4_Click(object sender, EventArgs e)
{
tChart1.Zoom.Undo();
}
I can run the project, zoom the chart with the mouse, and then click the button to successfully reset the chart. Could you please modify the above code snippet so I can reproduce your issue here?
Re: Unzoom
Posted: Tue Apr 21, 2015 10:20 am
by 15669761
All right
aspx:
Code: Select all
<tchart:WebChart ID="WebChart" runat="server" Height="228px" Width="542px" GetChartFile="GetChart.aspx" TempChart="Session" />
codebehind:
Code: Select all
private string SSN_KEY_CHART_DATA = "chartData";
protected void Page_Load(object sender, EventArgs e)
{
InitializeChart();
CheckZoom();
}
private void InitializeChart()
{
if (WebChart.Chart.Tools.Count == 0)
{
WebChart.Chart.Tools.Add(new ZoomTool());
}
RestoreState();
if (WebChart.Chart.Series.Count == 0)
{
Line series1;
WebChart.Chart.Aspect.View3D = false;
WebChart.Chart.Legend.Visible = false;
series1 = new Line(WebChart.Chart);
series1.FillSampleValues();
SaveState();
}
}
private System.IO.MemoryStream ChartData
{
get
{
if (Page.Session[SSN_KEY_CHART_DATA] == null)
{
Page.Session[SSN_KEY_CHART_DATA] = new System.IO.MemoryStream();
}
System.IO.MemoryStream tmp = Page.Session[SSN_KEY_CHART_DATA] as System.IO.MemoryStream;
tmp.Seek(0, System.IO.SeekOrigin.Begin);
return tmp;
}
set
{
Page.Session[SSN_KEY_CHART_DATA] = value;
}
}
public void SaveState()
{
ChartData = new System.IO.MemoryStream();
WebChart.Chart.Export.Template.Save(ChartData);
}
private void RestoreState()
{
if (ChartData.Length != 0)
{
WebChart.Chart.Import.Template.Load(ChartData);
}
}
private void CheckZoom()
{
ArrayList zoomedState = (ArrayList)Session[UniqueID + "Zoomed"];
ZoomTool zoomTool = (ZoomTool)WebChart.Chart.Tools[0];
zoomedState = zoomTool.SetCurrentZoom(Page.Request, zoomedState);
if (zoomedState == null)
{
Session.Remove(UniqueID + "Zoomed");
}
else
{
Page.Session.Add(UniqueID + "Zoomed", zoomedState);
}
}
protected void Button3_Click(object sender, EventArgs e)
{
WebChart.Chart.Zoom.Undo();
}
EDIT: The project I'm working on is an Asp.Net WebForm using .NET Framework 4
Re: Unzoom
Posted: Wed Apr 22, 2015 10:16 am
by Christopher
Hello Will,
Apologies for the fact that over twenty-four hours have passed without a response to your issue. Just to let you know that we are presently looking into it and that we hope to have a response for you very shortly.
Re: Unzoom
Posted: Thu Apr 23, 2015 1:08 pm
by Christopher
Will,
Two possible solutions, the first in the page-behind file, e.g.
Code: Select all
private void CheckZoom()
{
CheckZoom((ArrayList)Session[UniqueID + "Zoomed"]);
}
private void CheckZoom(ArrayList zoomedState)
{
ZoomTool zoomTool = (ZoomTool)WebChart1.Chart.Tools[0];
zoomedState = zoomTool.SetCurrentZoom(Page.Request, zoomedState);
if (zoomedState == null)
{
Session.Remove(UniqueID + "Zoomed");
}
else
{
Page.Session.Add(UniqueID + "Zoomed", zoomedState);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
CheckZoom(null);
Page_Load(sender, e);
}
and the second a javascript function in the page itself, e.g.
Code: Select all
</head>
<script type="text/javascript">
function resetZoom() {
__doPostBack(WebChart1, 'chart$WebChart1;zoom$0');
}
</script>
<body>
<form id="form1" runat="server">
<div>
</div>
<tchart:WebChart ID="WebChart1" runat="server" Height="500px" Width="800px" GetChartFile="GetChart.aspx" TempChart="Session" />
<!--<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />-->
<button type="button" onclick="resetZoom();">ResetZoom</button>
</form>
</body>
Re: Unzoom
Posted: Fri Apr 24, 2015 5:02 am
by 15669761
I used the first solution and it's working,
thank you