Group: Forum Members
Last Active: 8 Years Ago
Posts: 99,
Visits: 654
|
I've been successful in my ASP.NET application displaying charts and am now working on making them interactive. I've been following the "HTML Image Map with Postback (Server Events) 2" Nevron Web Example under the "Web Control -> Interactive Charting" section. I've been mostly successful processing a Click event on a series data point this way. Occasionally, however, I've been experiencing an ArgumentOutOfRangeException on the FindInDocument call below: private void chart_Click(object sender, EventArgs e) { try { NPostbackEventArgs eventArgs = e as NPostbackEventArgs; NDataPoint dp = eventArgs.Id.FindInDocument(chart.Document) as NDataPoint; if (dp != null) { ... } } catch (Exception) { } }
private void chart_Click(object sender, EventArgs e) {
try {
NPostbackEventArgs eventArgs = e as NPostbackEventArgs;
NDataPoint dp = eventArgs.Id.FindInDocument(chart.Document) as NDataPoint;
if (dp != null) {
...
}
} catch (Exception)
{
}
}
When this exception happens the eventArgs.Id value for example is 2.89.1 but when it works successfully for that same data point its 2.88.1. It would seem somehow my document Ids are incorrect somehow but I don't know what I would have done to cause this. I would appreciate any ideas on how to research this issue. Here's some of my code-behind chart creation code: chart.BackgroundStyle.FrameStyle.Visible = false; chart.Panels.Clear(); chart.Charts.Clear(); chart.Legends.Clear(); NLegend legend = new NLegend(); legend.DockMode = PanelDockMode.Bottom; legend.Data.ExpandMode = LegendExpandMode.ColsFixed; legend.Data.ColCount = 2; legend.Mode = LegendMode.Automatic; legend.BoundsMode = BoundsMode.Fit; legend.OuterLeftBorderStyle.Width = new NLength(0); legend.OuterTopBorderStyle.Width = new NLength(0); legend.OuterRightBorderStyle.Width = new NLength(0); legend.OuterBottomBorderStyle.Width = new NLength(0); legend.HorizontalBorderStyle.Width = new NLength(0); legend.VerticalBorderStyle.Width = new NLength(0); legend.FillStyle.SetTransparencyPercent(100); legend.Visible = true; chart.Panels.Add(legend);
NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.DisplayOnLegend = legend; chart.Margins = new NMarginsL(0, 10, 0, 0); chart.Visible = true; chart.Panels.Add(chart);
NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.Interlaced = true; stripStyle.Begin = 0; stripStyle.End = 10; stripStyle.Infinite = true; stripStyle.Interval = 1; stripStyle.Length = 1;
NScaleConfigurator YScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; YScale.StripStyles.Clear(); YScale.StripStyles.Add(stripStyle); YScale.Title.Text = Resources.Resource.titleValuationIndex;
NAxis secYAxis = chart.Axis(StandardAxis.SecondaryY); secYAxis.Visible = true; secYAxis.Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true); NLinearScaleConfigurator SYScale = secYAxis.ScaleConfigurator as NLinearScaleConfigurator; SYScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; SYScale.Title.Text = "Relative Movement";
NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90); dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.TopLeft; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; setValIndexXAxisInterval();
NLineSeries lineValIndex = (NLineSeries)chart.Series.Add(SeriesType.Line); lineValIndex.Name = Resources.Resource.titleValuationIndex; lineValIndex.InflateMargins = true; lineValIndex.DataLabelStyle.Visible = false; lineValIndex.MarkerStyle.Visible = true; lineValIndex.MarkerStyle.PointShape = PointShape.Cylinder; lineValIndex.ShadowStyle.Type = ShadowType.GaussianBlur; lineValIndex.ShadowStyle.Offset = new NPointL(3, 3); lineValIndex.ShadowStyle.FadeLength = new NLength(5); lineValIndex.UseXValues = true;
NLineSeries lineValIndexIndex = (NLineSeries)chart.Series.Add(SeriesType.Line); lineValIndexIndex.Name = Resources.Resource.titleIndex; lineValIndexIndex.Visible = false; lineValIndexIndex.InflateMargins = true; lineValIndexIndex.UseXValues = true; lineValIndexIndex.DataLabelStyle.Visible = false; lineValIndexIndex.MarkerStyle.Visible = false; lineValIndexIndex.DisplayOnAxis(StandardAxis.PrimaryY, false); lineValIndexIndex.DisplayOnAxis(StandardAxis.SecondaryY, true);
... Fill chart series and set NMarkerStyles as needed
NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse(); imageMapResponse.GridCellSize = 2; chart.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse;
chart.Click += new EventHandler(chart_Click);
chart.BackgroundStyle.FrameStyle.Visible = false;
chart.Panels.Clear();
chart.Charts.Clear();
chart.Legends.Clear();
NLegend legend = new NLegend();
legend.DockMode = PanelDockMode.Bottom;
legend.Data.ExpandMode = LegendExpandMode.ColsFixed;
legend.Data.ColCount = 2;
legend.Mode = LegendMode.Automatic;
legend.BoundsMode = BoundsMode.Fit;
legend.OuterLeftBorderStyle.Width = new NLength(0);
legend.OuterTopBorderStyle.Width = new NLength(0);
legend.OuterRightBorderStyle.Width = new NLength(0);
legend.OuterBottomBorderStyle.Width = new NLength(0);
legend.HorizontalBorderStyle.Width = new NLength(0);
legend.VerticalBorderStyle.Width = new NLength(0);
legend.FillStyle.SetTransparencyPercent(100);
legend.Visible = true;
chart.Panels.Add(legend);
NCartesianChart chart = new NCartesianChart();
chart.DockMode = PanelDockMode.Fill;
chart.BoundsMode = BoundsMode.Stretch;
chart.DisplayOnLegend = legend;
chart.Margins = new NMarginsL(0, 10, 0, 0);
chart.Visible = true;
chart.Panels.Add(chart);
NScaleStripStyle stripStyle = new NScaleStripStyle();
stripStyle.SetShowAtWall(ChartWallType.Back, true);
stripStyle.Interlaced = true;
stripStyle.Begin = 0;
stripStyle.End = 10;
stripStyle.Infinite = true;
stripStyle.Interval = 1;
stripStyle.Length = 1;
NScaleConfigurator YScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
YScale.StripStyles.Clear();
YScale.StripStyles.Add(stripStyle);
YScale.Title.Text = Resources.Resource.titleValuationIndex;
NAxis secYAxis = chart.Axis(StandardAxis.SecondaryY);
secYAxis.Visible = true;
secYAxis.Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true);
NLinearScaleConfigurator SYScale = secYAxis.ScaleConfigurator as NLinearScaleConfigurator;
SYScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { };
SYScale.Title.Text = "Relative Movement";
NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();
dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90);
dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.TopLeft;
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale;
setValIndexXAxisInterval();
NLineSeries lineValIndex = (NLineSeries)chart.Series.Add(SeriesType.Line);
lineValIndex.Name = Resources.Resource.titleValuationIndex;
lineValIndex.InflateMargins = true;
lineValIndex.DataLabelStyle.Visible = false;
lineValIndex.MarkerStyle.Visible = true;
lineValIndex.MarkerStyle.PointShape = PointShape.Cylinder;
lineValIndex.ShadowStyle.Type = ShadowType.GaussianBlur;
lineValIndex.ShadowStyle.Offset = new NPointL(3, 3);
lineValIndex.ShadowStyle.FadeLength = new NLength(5);
lineValIndex.UseXValues = true;
NLineSeries lineValIndexIndex = (NLineSeries)chart.Series.Add(SeriesType.Line);
lineValIndexIndex.Name = Resources.Resource.titleIndex;
lineValIndexIndex.Visible = false;
lineValIndexIndex.InflateMargins = true;
lineValIndexIndex.UseXValues = true;
lineValIndexIndex.DataLabelStyle.Visible = false;
lineValIndexIndex.MarkerStyle.Visible = false;
lineValIndexIndex.DisplayOnAxis(StandardAxis.PrimaryY, false);
lineValIndexIndex.DisplayOnAxis(StandardAxis.SecondaryY, true);
... Fill chart series and set NMarkerStyles as needed
NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse();
imageMapResponse.GridCellSize = 2;
chart.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse;
chart.Click += new EventHandler(chart_Click);
|
Group: Forum Members
Last Active: Last Month
Posts: 3,055,
Visits: 4,052
|
Hi Craig, We tested the control with the attached code and it was working properly - note that in postback the control state must be identical to the one the first time the control renders (otherwise the ids may differ). We would also recommend you to thin web / server side events if you want interactive charting as they don't result in postback and are much faster. If you still want to use postback the thin web control also supports it. Let us know if the problem persists.
Best Regards, Nevron Support Team
|