User (Legacy) Posted May 19, 2004 Report Share Posted May 19, 2004 When the chart is zoomed, the MarkerToPixel(series, point) method throws a NullReferenceException if the specified point is outside of the Y-axis scroll view. Workaround: Use Axis.GetScrollView(), and call MarkerToPixel only if Value[series, point] is in the returned range. I use the latest version of chartFX 6.2 on .Net framework 1.0. Bernt Brenna Link to comment Share on other sites More sharing options...
Software FX Posted May 19, 2004 Report Share Posted May 19, 2004 We are unable to reproduce this behavior. On a "default chart" with 100 points, I zoom-in from 1 to 20 and call MarkerToPixel on point #50 and get to exception. Do you have a repro case ? -- FP Software FX Link to comment Share on other sites More sharing options...
User (Legacy) Posted May 20, 2004 Author Report Share Posted May 20, 2004 Visibility along the x-axis does not cause problems for me either. From my original posting: "...if the specified point is outside of the Y-axis scroll view." To reproduce, zoom in on a single point and call markertopixwel on a point that lies far from this point in y-value. Bernt "SoftwareFX Support" <noreply@softwarefx.com> wrote in message news:VqR704bPEHA.3152@webserver3.softwarefx.com... > We are unable to reproduce this behavior. > > On a "default chart" with 100 points, I zoom-in from 1 to 20 and call > MarkerToPixel on point #50 and get to exception. > > Do you have a repro case ? > > -- > FP > Software FX > > Link to comment Share on other sites More sharing options...
User (Legacy) Posted May 20, 2004 Author Report Share Posted May 20, 2004 Below (and in the attached MarkerToPixelForm.cs file) is a code example that reproduces the error. Include the code in a winform project with references set to the chartfx assemblies. The code in form_load will throw the exception, as will the code that is run when the button is clicked. Bernt Brenna <code> using System; using System.Drawing; using System.Windows.Forms; using SoftwareFX.ChartFX; public class MarkerToPixelForm : Form { private Chart chart; private Button button; private TextBox textBox; public MarkerToPixelForm() { chart = new Chart(); chart.Location = new Point(0, 0); chart.Size = new Size(ClientSize.Width, ClientSize.Height - 100); chart.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; chart.Dock = DockStyle.Fill; chart.Gallery = Gallery.Lines; chart.ToolBar = true; chart.OpenData(COD.Values, 2, 5); for (int i = 0; i < 5; i++) { chart.Value[0, i] = 10; chart.Value[1, i] = 5; } chart.CloseData(COD.Values); chart.AxisY.Max = 15; Controls.Add(chart); button = new Button(); button.Text = "M_To_P"; button.Click += new EventHandler(button_Click); button.Location = new Point(ClientSize.Width - button.Width, ClientSize.Height - button.Height); button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; Controls.Add(button); button.BringToFront(); textBox = new TextBox(); textBox.Text = "1,1"; textBox.Location = new Point(button.Left - textBox.Width, button.Top); textBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; Controls.Add(textBox); textBox.BringToFront(); Load += new EventHandler(form_Load); } private void displayMarkerToPixelResult() { string result = null; try { string[] coordinates = textBox.Text.Split(','); int series = int.Parse(coordinates[0]); int point = int.Parse(coordinates[1]); Point p = chart.MarkerToPixel(series, point); result = p.ToString(); } catch (Exception e) { result = e.Message; } MessageBox.Show(string.Format("MarkerToPixel({0})={1}", textBox.Text, result)); } private void button_Click(object sender, EventArgs eventArgs) { displayMarkerToPixelResult(); } private void form_Load(object sender, EventArgs eventArgs) { chart.AxisY.Zoom(7, 12); chart.AxisX.Zoom(1.5, 4.5); displayMarkerToPixelResult(); } /// <summary> /// The main entry point for the application. /// </summary> [sTAThread] static void Main() { Application.Run(new MarkerToPixelForm()); } } </code> "SoftwareFX Support" <noreply@softwarefx.com> wrote in message news:VqR704bPEHA.3152@webserver3.softwarefx.com... > We are unable to reproduce this behavior. > > On a "default chart" with 100 points, I zoom-in from 1 to 20 and call > MarkerToPixel on point #50 and get to exception. > > Do you have a repro case ? > > -- > FP > Software FX > > Link to comment Share on other sites More sharing options...
Software FX Posted May 24, 2004 Report Share Posted May 24, 2004 Hi Bernt, The issue is related to the zoom. Because the marker is not in the zoom area and has not been painted, the MarkerToPixel value for the selected marker does not actually exist, thus returning that error. Modifying the code as follows allows the expected results to be created: //chart.AxisY.Zoom(7, 12); //chart.AxisX.Zoom(1.5, 4.5); Kind regards, RH Software FX, Inc. "Bernt Brenna" <anonymous@discussions.microsoft.com> wrote in message news:IQpsbYpPEHA.3152@webserver3.softwarefx.com... > Below (and in the attached MarkerToPixelForm.cs file) is a code example that > reproduces the error. > > Include the code in a winform project with references set to the chartfx > assemblies. > > The code in form_load will throw the exception, as will the code that is run > when the button is clicked. > > Bernt Brenna > > <code> > using System; > using System.Drawing; > using System.Windows.Forms; > using SoftwareFX.ChartFX; > > > public class MarkerToPixelForm : Form > { > > private Chart chart; > private Button button; > private TextBox textBox; > > > public MarkerToPixelForm() > { > chart = new Chart(); > > chart.Location = new Point(0, 0); > chart.Size = new Size(ClientSize.Width, ClientSize.Height - 100); > chart.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | > AnchorStyles.Bottom; > chart.Dock = DockStyle.Fill; > chart.Gallery = Gallery.Lines; > chart.ToolBar = true; > > chart.OpenData(COD.Values, 2, 5); > > for (int i = 0; i < 5; i++) > { > chart.Value[0, i] = 10; > chart.Value[1, i] = 5; > } > > chart.CloseData(COD.Values); > chart.AxisY.Max = 15; > > Controls.Add(chart); > > button = new Button(); > button.Text = "M_To_P"; > button.Click += new EventHandler(button_Click); > button.Location = new Point(ClientSize.Width - button.Width, > ClientSize.Height - button.Height); > button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; > Controls.Add(button); > button.BringToFront(); > > textBox = new TextBox(); > textBox.Text = "1,1"; > textBox.Location = new Point(button.Left - textBox.Width, button.Top); > textBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; > Controls.Add(textBox); > textBox.BringToFront(); > > Load += new EventHandler(form_Load); > } > > > private void displayMarkerToPixelResult() > { > string result = null; > > try > { > string[] coordinates = textBox.Text.Split(','); > > int series = int.Parse(coordinates[0]); > int point = int.Parse(coordinates[1]); > > Point p = chart.MarkerToPixel(series, point); > > result = p.ToString(); > } > catch (Exception e) > { > result = e.Message; > } > > MessageBox.Show(string.Format("MarkerToPixel({0})={1}", textBox.Text, > result)); > } > > > private void button_Click(object sender, EventArgs eventArgs) > { > displayMarkerToPixelResult(); > } > > > private void form_Load(object sender, EventArgs eventArgs) > { > chart.AxisY.Zoom(7, 12); > chart.AxisX.Zoom(1.5, 4.5); > > displayMarkerToPixelResult(); > } > > > > > > /// <summary> > /// The main entry point for the application. > /// </summary> > [sTAThread] > static void Main() > { > Application.Run(new MarkerToPixelForm()); > } > > > } > > </code> > > > "SoftwareFX Support" <noreply@softwarefx.com> wrote in message > news:VqR704bPEHA.3152@webserver3.softwarefx.com... > > We are unable to reproduce this behavior. > > > > On a "default chart" with 100 points, I zoom-in from 1 to 20 and call > > MarkerToPixel on point #50 and get to exception. > > > > Do you have a repro case ? > > > > -- > > FP > > Software FX > > > > > > > Link to comment Share on other sites More sharing options...
User (Legacy) Posted June 3, 2004 Author Report Share Posted June 3, 2004 There are no "expected results" here. The code sample just reproduces a BUG in your software. Bernt Brenna "Software FX, RH" <noreply> wrote in message news:aTd9okbQEHA.3120@webserver3.softwarefx.com... > Hi Bernt, > > > > The issue is related to the zoom. Because the marker is not in the zoom > area and has not been painted, the MarkerToPixel value for the selected > marker does not actually exist, thus returning that error. Modifying the > code as follows allows the expected results to be created: > > //chart.AxisY.Zoom(7, 12); > > //chart.AxisX.Zoom(1.5, 4.5); > > > > Kind regards, > > RH > > Software FX, Inc. > > > > "Bernt Brenna" <anonymous@discussions.microsoft.com> wrote in message > news:IQpsbYpPEHA.3152@webserver3.softwarefx.com... > > Below (and in the attached MarkerToPixelForm.cs file) is a code example > that > > reproduces the error. > > > > Include the code in a winform project with references set to the chartfx > > assemblies. > > > > The code in form_load will throw the exception, as will the code that is > run > > when the button is clicked. > > > > Bernt Brenna > > > > <code> > > using System; > > using System.Drawing; > > using System.Windows.Forms; > > using SoftwareFX.ChartFX; > > > > > > public class MarkerToPixelForm : Form > > { > > > > private Chart chart; > > private Button button; > > private TextBox textBox; > > > > > > public MarkerToPixelForm() > > { > > chart = new Chart(); > > > > chart.Location = new Point(0, 0); > > chart.Size = new Size(ClientSize.Width, ClientSize.Height - 100); > > chart.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top > | > > AnchorStyles.Bottom; > > chart.Dock = DockStyle.Fill; > > chart.Gallery = Gallery.Lines; > > chart.ToolBar = true; > > > > chart.OpenData(COD.Values, 2, 5); > > > > for (int i = 0; i < 5; i++) > > { > > chart.Value[0, i] = 10; > > chart.Value[1, i] = 5; > > } > > > > chart.CloseData(COD.Values); > > chart.AxisY.Max = 15; > > > > Controls.Add(chart); > > > > button = new Button(); > > button.Text = "M_To_P"; > > button.Click += new EventHandler(button_Click); > > button.Location = new Point(ClientSize.Width - button.Width, > > ClientSize.Height - button.Height); > > button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; > > Controls.Add(button); > > button.BringToFront(); > > > > textBox = new TextBox(); > > textBox.Text = "1,1"; > > textBox.Location = new Point(button.Left - textBox.Width, button.Top); > > textBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; > > Controls.Add(textBox); > > textBox.BringToFront(); > > > > Load += new EventHandler(form_Load); > > } > > > > > > private void displayMarkerToPixelResult() > > { > > string result = null; > > > > try > > { > > string[] coordinates = textBox.Text.Split(','); > > > > int series = int.Parse(coordinates[0]); > > int point = int.Parse(coordinates[1]); > > > > Point p = chart.MarkerToPixel(series, point); > > > > result = p.ToString(); > > } > > catch (Exception e) > > { > > result = e.Message; > > } > > > > MessageBox.Show(string.Format("MarkerToPixel({0})={1}", textBox.Text, > > result)); > > } > > > > > > private void button_Click(object sender, EventArgs eventArgs) > > { > > displayMarkerToPixelResult(); > > } > > > > > > private void form_Load(object sender, EventArgs eventArgs) > > { > > chart.AxisY.Zoom(7, 12); > > chart.AxisX.Zoom(1.5, 4.5); > > > > displayMarkerToPixelResult(); > > } > > > > > > > > > > > > /// <summary> > > /// The main entry point for the application. > > /// </summary> > > [sTAThread] > > static void Main() > > { > > Application.Run(new MarkerToPixelForm()); > > } > > > > > > } > > > > </code> > > > > > > "SoftwareFX Support" <noreply@softwarefx.com> wrote in message > > news:VqR704bPEHA.3152@webserver3.softwarefx.com... > > > We are unable to reproduce this behavior. > > > > > > On a "default chart" with 100 points, I zoom-in from 1 to 20 and call > > > MarkerToPixel on point #50 and get to exception. > > > > > > Do you have a repro case ? > > > > > > -- > > > FP > > > Software FX > > > > > > > > > > > > > > Link to comment Share on other sites More sharing options...
Software FX Posted June 3, 2004 Report Share Posted June 3, 2004 Agree, this is a BUG, I think Rob was just trying to give you a workaround. The purpose of this newsgroup is to get help on how to use Chart FX, although we monitor it quite frequently, it is not intended as a bug reporting tool or as a direct support mechanism. I did posted the bug in our KB. It is fine to post bugs in this newsgroup, as a matter of fact we encourage it so that other users can benefit from this knowledge, however, if the bug is preventing you from using the product, you should contact our support department directly, they can bump-up the bug priority and even give you access to a hotfix that fixes the problem before a SP is released. -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.