Page 1 of 1
Zoom - ArgumentException was unhandled by user code
Posted: Thu Feb 09, 2006 6:36 am
by 6923298
Hi,
I'm not really sure how it happened. I copied the code from the demo into my webform and have set my TempChart to Session. It'll plot the curve as shown in the demo, but when I try to zoom, the following line in the CheckZoom function returns an error "ArgumentException was unhandled by user code - Parameter is not valid".
Code: Select all
zoomedState = ((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request, zoomedState);
Did I miss something? Thanks.
Posted: Thu Feb 09, 2006 10:28 am
by narcis
Hi dave,
Could you please send us an example we can run "as-is" or a code snippet we can use to reproduce the problem here?
You can post your files at [url]news://
www.steema.net/steema.public.attachments[/url] newsgroup.
Thanks in advance.
Posted: Thu Feb 09, 2006 11:30 pm
by 6923298
Hi,
I've managed to capture the exception:
System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height) at Steema.TeeChart.Chart.Bitmap(Int32 width, Int32 height, PixelFormat pixelformat) at Steema.TeeChart.Chart.Bitmap(Int32 width, Int32 height) at Steema.TeeChart.Chart.Bitmap() at Steema.TeeChart.Tools.ZoomTool.Zoom(Rectangle r) at Steema.TeeChart.Tools.ZoomTool.DoZoom(ArrayList zoomState) at Steema.TeeChart.Tools.ZoomTool.SetCurrentZoom(HttpRequest r, ArrayList zoomState) at TestZoom2.CheckZoom(WebChart wChart) in c:\user\visual studio 2005\projects\TestTChart\TestZoom2.aspx.cs:line 85
and the code for TestZoom2.aspx.cs is
Code: Select all
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using Steema.TeeChart.Web;
using Steema.TeeChart.Styles;
using Steema.TeeChart;
public partial class TestZoom2 : System.Web.UI.Page
{
protected Steema.TeeChart.Web.WebChart WebChart2;
protected Steema.TeeChart.Web.WebChart WebChart3;
protected System.Web.UI.WebControls.Button Button2;
protected Steema.TeeChart.Tools.ZoomTool zoomTool1;
protected Steema.TeeChart.Styles.Points points1;
protected Steema.TeeChart.Styles.Points points2;
protected Steema.TeeChart.Tools.ZoomTool zoomTool2;
protected void Page_Load(object sender, System.EventArgs e)
{
// // Put user code to initialize the page here
// WebChart1.Chart[0].FillSampleValues(10);
// WebChart2.Chart[0].FillSampleValues(10);
// WebChart3.Chart[0].FillSampleValues(10);
// ****************************************************
//The data load code for WebChart1 demostrates a technique to save
//data between page calls. The Chart is saved as a TeeChart template
//to a session variable.
// ****************************************************
Steema.TeeChart.Chart ch1 = WebChart1.Chart;
MemoryStream tmpChart = new MemoryStream();
if (Session["ch1"] == null)
{
//setup Chart
if (ch1.Series.Count < 2)
{
ch1.Series.Add(new Steema.TeeChart.Styles.Points());
ch1.Series.Add(new Steema.TeeChart.Styles.Points());
}
//((Steema.TeeChart.Tools.ZoomTool)ch1.Tools[0]).ZoomPenColor=Color.Yellow;
((Points)ch1.Series[0]).Pointer.Pen.Visible = false;
((Points)ch1.Series[1]).Pointer.Pen.Color = Color.FromArgb(79, 79, 255);
ch1.Series[0].Color = Color.FromArgb(255, 199, 26);
ch1.Series[1].Color = Color.FromArgb(106, 106, 255);
ch1.Series[0].FillSampleValues(36);
ch1.Series[1].FillSampleValues(36);
//export Chart to a MemoryStream template
ch1.Export.Template.Save(tmpChart);
//save template to a Session variable
Session.Add("ch1", tmpChart);
}
else
{
//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
WebChart1.Chart.Import.Template.Load(tmpChart);
//check whether zoom request is being sent
CheckZoom(WebChart1);
}
}
private void CheckZoom(WebChart wChart)
{
try
{
ArrayList zoomedState = (ArrayList)Session[wChart.ID + "Zoomed"];
zoomedState = ((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request,
zoomedState);
if (zoomedState == null)
Session.Remove(wChart.ID + "Zoomed");
else
Session.Add(wChart.ID + "Zoomed", zoomedState);
}
catch (Exception e)
{
Response.Write(e);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
// //Associate the Chart's Hotspot event with function
// ((Steema.TeeChart.Tools.SeriesHotspot)(WebChart1.Chart.Tools[0])).GetHTMLMap +=
// new Steema.TeeChart.Tools.SeriesHotspotEventHandler(hotspot1_GetHTMLMap);
//
// Steema.TeeChart.Tools.SeriesHotspot h1=((Steema.TeeChart.Tools.SeriesHotspot)(WebChart1.Chart.Tools[0]));
// h1.MapElements="onClick=\"alert('x: ' + event.x + ' y: ' + event.y);\"";
this.zoomTool1 = new Steema.TeeChart.Tools.ZoomTool(WebChart1.Chart);
this.points1 = new Steema.TeeChart.Styles.Points(WebChart1.Chart);
this.points2 = new Steema.TeeChart.Styles.Points(WebChart1.Chart);
this.zoomTool2 = new Steema.TeeChart.Tools.ZoomTool(WebChart1.Chart);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
}
#endregion
}
Thanks.
Posted: Fri Feb 10, 2006 11:40 am
by narcis
Hi dave,
Thanks for the code, I pasted it in a new project and worked fine for me. Does the ASP.NET demo, on the Start Menu\All Programs TeeChart for .NET v2 entry, works on your machine? Which TeeChart version are you using?
Thanks in advance.
Posted: Sun Feb 12, 2006 10:18 pm
by 6923298
Hi Narcis,
Yes, the ASP.NET demo works. I've tried putting the code into new projects/websites but I still have the same error.
I'm using .Net V2 Evaluation NET2005 version, but I also have TeeChart Pro v5 installed on my PC.
It's quite odd, because I adapted the code for another zoom function and it didn't have that error. But the zoom wasn't working well as I could never get it to zoom to the area I've selected.
Posted: Mon Feb 13, 2006 11:37 am
by narcis
Hi dave,
To find which is the problem we need to reproduce it here. Could you please send us an example we can run "as-is" to reproduce the problem here?
Thanks in advance.
Posted: Mon Feb 13, 2006 10:00 pm
by 6923298
Hi Narcis,
Could you provide an email address for me to send the files to? I don't have access to newsgroup from my work place.
Thanks.
Posted: Tue Feb 14, 2006 8:50 am
by narcis
Ok dave,
Please send them directly to me.
Thanks in advance.
Posted: Wed Feb 15, 2006 5:42 am
by 6923298
Hi Narcis,
I hope you have received my files. Pls note that I've changed my profile, previous username was my colleague's name.
Thanks.
Posted: Wed Feb 15, 2006 10:29 am
by narcis
Hi pw,
Yes, I noticed your nick change
.
Thanks for the files but I couldn't get a working project with them. Could you please send me a full project that we can run "as-is"?
Thanks in advance.
Posted: Thu Feb 23, 2006 5:37 pm
by narcis
Hi pw,
We finally found the problem. What happens is that VS2005 doesn't set WebChart's width and height until you manually resize the component on the form at design-time or you manually set the WebForm .aspx source for the WebChart like the example below. Please notice that Width and Height are set outside of the style property group.
Code: Select all
<tchart:WebChart ID="WebChart1" runat="server" AutoPostback="False" Config="AAEAAAD/////AQA...........UNoYXJ0Cw=="
GetChartFile="GetChart.aspx" Style="position: absolute; left: 45px; top: 45px;" TempChart="Cache" Height="334px" Width="450px" />
We will try to solve that for future releases.
Posted: Thu Feb 23, 2006 10:27 pm
by 6923298
Thank you very much Narcis, it worked!
I noticed that if I were to set the Height and Width but left out the Style, the zoom function will not correctly zoom to the selected area.
Do I have to set the Style Position as Absolute for all webcharts?
Thanks.
Posted: Fri Feb 24, 2006 8:45 am
by narcis
Hi pw,
You're welcome. I'm happy to hear that worked.
Do I have to set the Style Position as Absolute for all webcharts?
It shouldn't matter, the only thing you have to care about is the Width and Height being set and out the style.