public void OnAutoUpdate(NAspNetThinWebControl control) { NThinChartControl chartControl = (NThinChartControl)control; NLineSeries line = (NLineSeries)chartControl.Charts[0].Series[0]; if (line == null) { return; } if (line.Values.Count == 0) { return; } double dPrev = (double)line.Values[line.Values.Count - 1]; double yValue = GenerateDataPoint(dPrev, new NRange1DD(50, 350)); line.Values.RemoveAt(0); line.XValues.RemoveAt(0); line.Values.Add(yValue); line.XValues.Add(DateTime.Now.ToOADate()); chartControl.UpdateView(); }
public void OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinChartControl chartControl = (NThinChartControl)control; NPieChart pieChart = (NPieChart)chartControl.Charts[0]; NHitTestResult hitTestResult = chartControl.HitTest(e.X, e.Y); int dataPointIndex = hitTestResult.DataPointIndex; // collapse all pie slices NPieSeries pieSeries = (NPieSeries)pieChart.Series[0]; for (int i = 0; i < pieSeries.Values.Count; i++) { pieSeries.Detachments[i] = 0; } // expand the one that's hit if (dataPointIndex != -1) { pieSeries.Detachments[dataPointIndex] = 5.0f; } chartControl.UpdateView(); }
public override bool IsEnabled() { NThinChartControl control = (NThinChartControl)this.m_Control; NBarSeries bar = control.Charts[0].Series[0] as NBarSeries; return(bar.DataLabelStyle.Visible); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinChartControl chartControl = (NThinChartControl)control; NChart chart = chartControl.Charts[0]; NBarSeries bar = (NBarSeries)chart.Series[0]; bar.DataLabelStyles.Clear(); switch (argument) { case "ShowDataLabels": { bar.DataLabelStyle.Visible = true; } break; case "HideDataLabels": { bar.DataLabelStyle.Visible = false; } break; } // update the control and toolbar chartControl.Update(); }
void INAutoUpdateCallback.OnAutoUpdate(NAspNetThinWebControl control) { NThinChartControl chartControl = (NThinChartControl)control; NBarSeries bar = (NBarSeries)chartControl.Charts[0].Series[0]; int index = (int)chartControl.CustomData; for (int i = 0; i < bar.FillStyles.Count; i++) { NColorFillStyle colorFill = bar.FillStyles[i] as NColorFillStyle; if (i != index) { colorFill.Color = Color.FromArgb(60, colorFill.Color); } else { colorFill.Color = Color.FromArgb(255, colorFill.Color); } } index++; if (index >= bar.FillStyles.Count) { index = 0; } chartControl.CustomData = index; chartControl.UpdateView(); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinChartControl chartControl = (NThinChartControl)control; // make sure chart is recalculated chartControl.RecalcLayout(); NChart chart = chartControl.Charts[0]; NStockSeries stock = (NStockSeries)chart.Series[0]; switch (argument) { case "LastWeek": { DateTime dt = DateTime.FromOADate((double)stock.XValues[stock.XValues.Count - 1]); chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(dt.AddDays(-7).ToOADate(), dt.ToOADate()), 0.00001); } break; case "LastMonth": { DateTime dt = DateTime.FromOADate((double)stock.XValues[stock.XValues.Count - 1]); chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(dt.AddMonths(-1).ToOADate(), dt.ToOADate()), 0.00001); } break; case "LastYear": chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false; break; } chartControl.Update(); }
public ActionResult Service(string request) { NThinChartControl ntcc = new NThinChartControl(); NResponseOutput output = this.Control.ProcessRequest(request); return(new NThinControlResult(output)); }
public override void Initialize(NThinChartControl control) { control.BackgroundStyle.FrameStyle.Visible = false; control.Panels.Clear(); control.Width = 600; control.Height = 300; NStandardFrameStyle frame = control.BackgroundStyle.FrameStyle as NStandardFrameStyle; frame.InnerBorderWidth = new NLength(0); // set a chart title // set a chart title NLabel title = control.Labels.AddHeader("Auto Update"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup Line chart NCartesianChart chart = new NCartesianChart(); control.Panels.Add(chart); NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator(); rangeTimeline.FirstRow.MinTickDistance = new NLength(40); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); NLineSeries line = new NLineSeries(); line.UseXValues = true; line.DataLabelStyle.Visible = false; line.BorderStyle.Color = Color.DarkOrange; line.BorderStyle.Width = new NLength(2); chart.Series.Add(line); // generate some data GenerateNewData(control); ApplyLayoutTemplate(0, control, chart, title, null); // set auto update Callback control.AutoUpdateCallback = new NAutoUpdateCallback(); // enable auto update control.ServerSettings.AutoUpdateInterval = 200; control.ServerSettings.EnableAutoUpdate = true; }
public override void Initialize(NThinChartControl control) { control.BackgroundStyle.FrameStyle.Visible = false; control.Panels.Clear(); // Set manual ID so that it can be referenced in JavaScript control.StateId = "Chart1"; // set a chart title NLabel header = new NLabel("Custom Requests"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.DockMode = PanelDockMode.Top; header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); control.Panels.Add(header); NCartesianChart chart = new NCartesianChart(); InitChart(control, chart); // register a custom request callback control.CustomRequestCallback = new CustomRequestCallback(); control.ServerSettings.EnableTiledZoom = true; // configure toolbar control.Toolbar.Visible = true; control.Controller.SetActivePanel(chart); // add a data zoom tool NDataZoomTool dataZoomTool = new NDataZoomTool(); dataZoomTool.Exclusive = true; dataZoomTool.Enabled = false; dataZoomTool.AllowYAxisZoom = false; control.Controller.Tools.Add(dataZoomTool); // add a data pan tool NDataPanTool dataPanTool = new NDataPanTool(); dataPanTool.Exclusive = true; dataPanTool.Enabled = true; control.Controller.Tools.Add(dataPanTool); // add a tooltip tool control.Controller.Tools.Add(new NTooltipTool()); // add a cursor change tool control.Controller.Tools.Add(new NCursorTool()); control.Toolbar.Visible = true; control.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PNG", new NPngImageFormat(), true, new NSize(0, 0), 96))); control.Toolbar.Items.Add(new NToolbarSeparator()); control.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction())); }
/// <summary> /// Renders the initial content of the chart on the page /// </summary> /// <returns></returns> public ActionResult Content() { NThinChartControl control = this.Control; control.ConfigureInitialResponse(); Initialize(control); return(new NThinControlResult(control.ProcessResponses())); }
void INDataPanCallback.OnDataPan(NThinChartControl control, NCartesianChart chart, NAxis horzAxis, NAxis vertAxis) { control.RecalcLayout(); NLabel label = control.Labels[0]; label.Text = FormatLabel(horzAxis.Scale.RulerRange, vertAxis.Scale.RulerRange); control.Update(); }
public void InitChart(NThinChartControl control, NCartesianChart chart) { // set layout related properties chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(10, 0, 10, 10); control.Panels.Add(chart); // add interlace stripes NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; linearScale.StripStyles.Add(stripStyle); // show X axis zooming and scrolling chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; // apply work calendar to the X axis NWorkCalendar calendar = new NWorkCalendar(); NWeekDayRule weekDayRule = new NWeekDayRule(); WeekDayBit weekDays = WeekDayBit.None; weekDays |= WeekDayBit.Monday; weekDays |= WeekDayBit.Tuesday; weekDays |= WeekDayBit.Wednesday; weekDays |= WeekDayBit.Thursday; weekDays |= WeekDayBit.Friday; weekDayRule.WeekDays = weekDays; weekDayRule.Schedule.SetHourRange(0, 24, false); calendar.Rules.Add(weekDayRule); // apply calendar to scale NRangeTimelineScaleConfigurator timeline = new NRangeTimelineScaleConfigurator(); timeline.FirstRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; timeline.FirstRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(225, 225, 225)); timeline.FirstRow.UseGridStyle = true; timeline.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; timeline.SecondRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(215, 215, 215)); timeline.SecondRow.UseGridStyle = true; timeline.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; timeline.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); timeline.ThirdRow.UseGridStyle = true; timeline.EnableCalendar = false; timeline.Calendar = calendar; timeline.ThirdRow.EnableUnitSensitiveFormatting = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timeline; // generate data for this calendar AddData(chart, calendar); }
public ActionResult Content() { NThinChartControl control = this.Control; control.ConfigureInitialResponse(); control.ServerSettings.Css.StateHover = "border: 1px solid rgb(38, 148, 232);background: rgb(255, 0, 0);"; Initialize(control); return(new NThinControlResult(control.ProcessResponses())); }
void INScrollbarCallback.OnScroll(NThinChartControl control, NCartesianChart chart, NAxis axis) { control.RecalcLayout(); NAxis horzAxis = chart.Axis(StandardAxis.PrimaryX); NAxis vertAxis = chart.Axis(StandardAxis.PrimaryY); NLabel label = control.Labels[0]; label.Text = FormatLabel(horzAxis.Scale.RulerRange, vertAxis.Scale.RulerRange); control.Update(); }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinChartControl chartControl = (NThinChartControl)control; NPieChart pieChart = (NPieChart)chartControl.Charts[0]; NPieSeries pieSeries = (NPieSeries)pieChart.Series[0]; for (int i = 0; i < pieSeries.Values.Count; i++) { pieSeries.Detachments[i] = 5.0f; } chartControl.UpdateView(); }
void INAutoUpdateCallback.OnAutoUpdateStateChanged(NAspNetThinWebControl control) { // reset colors NThinChartControl chartControl = (NThinChartControl)control; NBarSeries bar = (NBarSeries)chartControl.Charts[0].Series[0]; int index = (int)chartControl.CustomData; for (int i = 0; i < bar.FillStyles.Count; i++) { NColorFillStyle colorFill = bar.FillStyles[i] as NColorFillStyle; colorFill.Color = Color.FromArgb(255, colorFill.Color); } chartControl.CustomData = 0; chartControl.UpdateView(); }
void INActivatePanelCallback.OnActivatePanel(NThinChartControl control, NContentPanel newActivePanel, NContentPanel oldActivePanel) { // when the currently active panel changes, change its border to prompt the user if (oldActivePanel != null) { oldActivePanel.BorderStyle = null; } if (newActivePanel != null) { NStrokeBorderStyle border = new NStrokeBorderStyle(BorderShape.RoundedRect); border.StrokeStyle.Color = Color.Red; newActivePanel.BorderStyle = border; } control.UpdateView(); }
/// <summary> /// Generates new random data /// </summary> /// <param name="control"></param> private void GenerateNewData(NThinChartControl control) { NLineSeries line = (NLineSeries)control.Charts[0].Series[0]; int count = 100; DateTime dateTime = DateTime.Now.AddMilliseconds(-count * 50); double prevValue = 100; double value; for (int i = 0; i < count; i++) { value = GenerateDataPoint(prevValue, new NRange1DD(50, 350)); dateTime = dateTime.AddMilliseconds(50); line.Values.Add(value); line.XValues.Add(dateTime.ToOADate()); prevValue = value; } }
void INIndicatorDragCallback.OnIndicatorValueChanged(NThinChartControl control, NGaugePanel gauge, NIndicator indicator, double oldValue, double newValue) { control.NumericDisplays[0].Value = indicator.Value; }
public override string GetScript() { NThinChartControl control = (NThinChartControl)this.m_Control; return("NClientNode.GetFromId(\'" + control.StateId + "\').ExecuteCustomRequest(\"HideDataLabels\");"); }
public override void Initialize(NThinChartControl control) { // enable jittering (full scene antialiasing) control.Settings.JitterMode = JitterMode.Enabled; control.Panels.Clear(); // apply background image border NImageFrameStyle frame = new NImageFrameStyle(); frame.Type = ImageFrameType.Raised; frame.BackgroundColor = Color.White; frame.BorderStyle.Color = Color.Gainsboro; control.BackgroundStyle.FrameStyle = frame; control.BackgroundStyle.FillStyle = new NGradientFillStyle(Color.White, Color.GhostWhite); // set a chart title NLabel title = new NLabel("Trackball Tool"); control.Panels.Add(title); title.DockMode = PanelDockMode.Top; title.Padding = new NMarginsL(4, 6, 4, 6); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the legend NLegend legend = new NLegend(); control.Panels.Add(legend); legend.DockMode = PanelDockMode.Right; legend.Padding = new NMarginsL(1, 1, 3, 3); legend.FillStyle.SetTransparencyPercent(50); legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // configure the chart NCartesianChart chart = new NCartesianChart(); control.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = true; chart.DisplayOnLegend = legend; chart.BoundsMode = BoundsMode.Fit; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.DockMode = PanelDockMode.Fill; chart.Padding = new NMarginsL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // setup the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; // add interlaced stripe for the Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axisY.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // hide the depth axis chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series and fill it with data NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Simple Bar Chart"; bar.BarShape = BarShape.SmoothEdgeBar; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); bar.DataLabelStyle.Visible = false; bar.AddDataPoint(new NDataPoint(16, "Spain")); bar.AddDataPoint(new NDataPoint(42, "France")); bar.AddDataPoint(new NDataPoint(56, "Germany")); bar.AddDataPoint(new NDataPoint(23, "Italy")); bar.AddDataPoint(new NDataPoint(47, "UK")); bar.AddDataPoint(new NDataPoint(38, "Sweden")); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor); styleSheet.Apply(bar); //control.Controller.EnableAutoUpdate = true; NTrackballTool tbt = new NTrackballTool(); tbt.Exclusive = true; tbt.Enabled = true; control.Controller.SetActivePanel(chart); control.Controller.Tools.Add(tbt); }
void INTrackballCallback.OnTrackball(NThinChartControl control, NChart chart, float oldRotation, float oldElevation) { control.Labels[0].Text = "Trackball Tool<br/><font size='10pt'> Rotation[" + chart.Projection.Rotation.ToString() + "], Elevation [" + chart.Projection.Elevation.ToString() + "]</font>"; control.UpdateView(); }
public override void Initialize(NThinChartControl control) { NServerMouseEventTool serverMouseEventTool; // enable jittering (full scene antialiasing) control.Settings.JitterMode = JitterMode.Enabled; control.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = control.Labels.AddHeader("Exploded Pie Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup legend NLegend legend = control.Legends[0]; legend.FillStyle.SetTransparencyPercent(50); legend.Data.ExpandMode = LegendExpandMode.RowsFixed; legend.Data.RowCount = 2; legend.ContentAlignment = ContentAlignment.TopLeft; legend.Location = new NPointL( new NLength(99, NRelativeUnit.ParentPercentage), new NLength(99, NRelativeUnit.ParentPercentage)); // by default the control contains a Cartesian chart -> remove it and create a Pie chart NChart chart = new NPieChart(); control.Charts.Clear(); control.Charts.Add(chart); // configure the chart chart.Enable3D = true; chart.DisplayOnLegend = control.Legends[0]; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL( new NLength(12, NRelativeUnit.ParentPercentage), new NLength(12, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(76, NRelativeUnit.ParentPercentage), new NLength(68, NRelativeUnit.ParentPercentage)); // add a pie serires NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.SmoothEdgePie; pie.PieEdgePercent = 50; pie.DataLabelStyle.Visible = false; pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.Legend.Format = "<label> <percent>"; pie.Legend.TextStyle.FontStyle = new NFontStyle("Arial", 8); pie.AddDataPoint(new NDataPoint(0, "Ships")); pie.AddDataPoint(new NDataPoint(0, "Trains")); pie.AddDataPoint(new NDataPoint(0, "Cars")); pie.AddDataPoint(new NDataPoint(0, "Buses")); pie.AddDataPoint(new NDataPoint(0, "Airplanes")); pie.Values.FillRandomRange(new Random(), pie.Values.Count, 1, 20); for (int i = 0; i < pie.Values.Count; i++) { pie.Detachments.Add(0); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor); styleSheet.Apply(control.Document); // configure the controller serverMouseEventTool = new NServerMouseEventTool(); control.Controller.Tools.Add(serverMouseEventTool); serverMouseEventTool.MouseDown = new NDetachPieSliceMouseEventCallback(); }
public override void Initialize(NThinChartControl control) { // enable jittering (full scene antialiasing) control.BackgroundStyle.FrameStyle.Visible = false; control.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = control.Labels.AddHeader("Interactivity Tools<br/>Tooltip, Browser Redirect, Cursor Change"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.TextStyle.TextFormat = TextFormat.XML; // setup the chart NChart chart = control.Charts[0]; chart.Enable3D = true; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.DataLabelStyle.Visible = false; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.Format = "<label> <percent>"; bar.AddDataPoint(new NDataPoint(42, "Chart")); bar.AddDataPoint(new NDataPoint(56, "Diagram")); bar.AddDataPoint(new NDataPoint(12, "Gauges")); bar.AddDataPoint(new NDataPoint(23, "Maps")); // modify the axis labels NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.AutoLabels = false; for (int i = 0; i < bar.Labels.Count; i++) { ordinalScale.Labels.Add((string)bar.Labels[i]); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.PaleMultiColor); styleSheet.Apply(chart); // apply layout ApplyLayoutTemplate(0, control, chart, title, control.Legends[0]); // add interactivity styles with the urls to redirect to and the corresponding cursors and tooltips NInteractivityStyle interactivityStyle = new NInteractivityStyle("Click here to jump to Chart Gallery", CursorType.Hand); interactivityStyle.UrlLink.OpenInNewWindow = true; interactivityStyle.UrlLink.Url = "http://www.nevron.com/Gallery.ChartFor.NET.ChartTypes.BarChartGallery.aspx"; bar.InteractivityStyles[0] = interactivityStyle; interactivityStyle = new NInteractivityStyle("Click here to jump to Diagram Gallery", CursorType.Hand); interactivityStyle.UrlLink.OpenInNewWindow = true; interactivityStyle.UrlLink.Url = "http://www.nevron.com/Gallery.DiagramFor.NET.FlowAndOrganizationCharts.Flowcharts.aspx"; bar.InteractivityStyles[1] = interactivityStyle; interactivityStyle = new NInteractivityStyle("Click here to jump to Gauge Gallery", CursorType.Hand); interactivityStyle.UrlLink.OpenInNewWindow = true; interactivityStyle.UrlLink.Url = "http://www.nevron.com/Gallery.ChartFor.NET.Gauges.RadialGaugeGallery.aspx"; bar.InteractivityStyles[2] = interactivityStyle; interactivityStyle = new NInteractivityStyle("Click here to jump to Maps Gallery", CursorType.Hand); interactivityStyle.UrlLink.OpenInNewWindow = true; interactivityStyle.UrlLink.Url = "http://www.nevron.com/Gallery.DiagramFor.NET.Maps.MapProjections.aspx"; bar.InteractivityStyles[3] = interactivityStyle; control.Controller.Tools.Add(new NTooltipTool()); control.Controller.Tools.Add(new NBrowserRedirectTool()); control.Controller.Tools.Add(new NCursorTool()); control.Controller.Tools.Clear(); // add browser redirect tool control.Controller.Tools.Add(new NBrowserRedirectTool()); // add tooltip tool that follows the mouse NTooltipTool tooltipTool = new NTooltipTool(); tooltipTool.FollowMouse = true; control.Controller.Tools.Add(tooltipTool); // add a cursor change tool control.Controller.Tools.Add(new NCursorTool()); }
/// <summary> /// Called when the control has to be initialized /// </summary> /// <param name="control"></param> public abstract void Initialize(NThinChartControl control);
public override void Initialize(NThinChartControl control) { control.BackgroundStyle.FrameStyle.Visible = false; control.Panels.Clear(); // set a chart title NLabel header = new NLabel("Indicator Drag Tool"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); control.Panels.Add(header); // create the radial gauge NRadialGaugePanel m_RadialGauge = new NRadialGaugePanel(); m_RadialGauge.BorderStyle = new NEdgeBorderStyle(BorderShape.Auto); m_RadialGauge.PaintEffect = new NGlassEffectStyle(); m_RadialGauge.ContentAlignment = ContentAlignment.MiddleCenter; m_RadialGauge.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(52, NRelativeUnit.ParentPercentage)); m_RadialGauge.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(85, NRelativeUnit.ParentPercentage)); m_RadialGauge.BackgroundFillStyle = new NGradientFillStyle(Color.DarkGray, Color.Black); // configure scale NGaugeAxis axis = (NGaugeAxis)m_RadialGauge.Axes[0]; NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator; scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Presentation); scale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 10, FontStyle.Bold); scale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.White); scale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); scale.MinorTickCount = 4; scale.RulerStyle.BorderStyle.Width = new NLength(0); scale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGray); // add radial gauge indicators NRangeIndicator rangeIndicator = new NRangeIndicator(); rangeIndicator.Value = 20; rangeIndicator.FillStyle = new NGradientFillStyle(Color.Yellow, Color.Red); rangeIndicator.StrokeStyle.Color = Color.DarkBlue; rangeIndicator.EndWidth = new NLength(20); NInteractivityStyle interactivityStyle1 = new NInteractivityStyle(); interactivityStyle1.Tooltip.Text = "Drag Me"; // interactivityStyle1.ClientMouseEventAttribute.Tag = "Indicator[" + m_Indicator1.UniqueId.ToString() + "]"; rangeIndicator.InteractivityStyle = interactivityStyle1; m_RadialGauge.Indicators.Add(rangeIndicator); NNeedleValueIndicator needleIndicator = new NNeedleValueIndicator(); needleIndicator.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); needleIndicator.Shape.StrokeStyle.Color = Color.Red; m_RadialGauge.Indicators.Add(needleIndicator); m_RadialGauge.SweepAngle = 270; // add radial gauge control.Panels.Add(m_RadialGauge); // create and config ure a numeric display attached to the radial gauge NNumericDisplayPanel numericDisplay = new NNumericDisplayPanel(); numericDisplay.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); numericDisplay.ContentAlignment = ContentAlignment.TopCenter; numericDisplay.DisplayStyle = DisplayStyle.SevenSegmentRounded; numericDisplay.SegmentWidth = new NLength(2, NGraphicsUnit.Point); numericDisplay.SegmentGap = new NLength(1, NGraphicsUnit.Point); numericDisplay.CellSize = new NSizeL(new NLength(9, NGraphicsUnit.Point), new NLength(19, NGraphicsUnit.Point)); numericDisplay.ShowDecimalSeparator = true; numericDisplay.ShowLeadingZeros = true; numericDisplay.EnableDecimalFormatting = false; numericDisplay.CellCountMode = DisplayCellCountMode.Auto; numericDisplay.CellCount = 6; numericDisplay.ValueFormatter = new NNumericValueFormatter("00.00"); numericDisplay.CellAlignment = VertAlign.Top; numericDisplay.BackgroundFillStyle = new NColorFillStyle(Color.DimGray); numericDisplay.LitFillStyle = new NGradientFillStyle(Color.Lime, Color.Green); numericDisplay.CellCountMode = DisplayCellCountMode.Fixed; numericDisplay.CellCount = 6; numericDisplay.Padding = new NMarginsL(3, 2, 3, 2); m_RadialGauge.ChildPanels.Add(numericDisplay); // create a sunken border around the display NEdgeBorderStyle borderStyle = new NEdgeBorderStyle(BorderShape.RoundedRect); borderStyle.OuterBevelWidth = new NLength(0); borderStyle.MiddleBevelWidth = new NLength(0); numericDisplay.BorderStyle = borderStyle; NIndicatorDragTool indicatorDragTool = new NIndicatorDragTool(); indicatorDragTool.IndicatorDragCallback = new IndicatorDragCallback(); control.Controller.Tools.Add(indicatorDragTool); control.Controller.Tools.Add(new NTooltipTool()); NRangeIndicator range = (NRangeIndicator)control.Gauges[0].Indicators[0]; range.AllowDragging = true; if (range.AllowDragging) { range.InteractivityStyle.Tooltip.Text = "Drag Me"; } else { range.InteractivityStyle.Tooltip.Text = range.Range.End.ToString(); } NNeedleValueIndicator needle = (NNeedleValueIndicator)control.Gauges[0].Indicators[1]; needle.AllowDragging = true; if (needle.AllowDragging) { needle.InteractivityStyle.Tooltip.Text = "Drag Me"; } else { needle.InteractivityStyle.Tooltip.Text = needle.Value.ToString(); } }
public override void Initialize(NThinChartControl control) { // enable jittering (full scene antialiasing) control.Settings.JitterMode = JitterMode.Enabled; control.ServerSettings.EnableTiledZoom = true; control.Panels.Clear(); // apply background image border NImageFrameStyle frame = new NImageFrameStyle(); frame.Type = ImageFrameType.Raised; frame.BackgroundColor = Color.White; frame.BorderStyle.Color = Color.Gainsboro; control.BackgroundStyle.FrameStyle = frame; control.BackgroundStyle.FillStyle = new NGradientFillStyle(Color.White, Color.GhostWhite); // set a chart title NLabel title = new NLabel("Welcome to Nevron Chart for .NET"); control.Panels.Add(title); title.DockMode = PanelDockMode.Top; title.Padding = new NMarginsL(4, 6, 4, 6); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the legend NLegend legend = new NLegend(); control.Panels.Add(legend); legend.DockMode = PanelDockMode.Right; legend.Padding = new NMarginsL(1, 1, 3, 3); legend.FillStyle.SetTransparencyPercent(50); legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // configure the chart NCartesianChart chart = new NCartesianChart(); control.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = true; chart.DisplayOnLegend = legend; chart.BoundsMode = BoundsMode.Fit; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.DockMode = PanelDockMode.Fill; chart.Padding = new NMarginsL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(Color.White, Color.Gray); // setup the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); axisX.ScrollBar.Visible = true; NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.AutoLabels = false; // add interlaced stripe for the Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); axisY.ScrollBar.Visible = true; NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axisY.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // hide the depth axis chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series and fill it with data NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Simple Bar Chart"; bar.BarShape = BarShape.SmoothEdgeBar; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); bar.DataLabelStyle.Visible = false; AddDataPoint(scaleX, bar, 16, "Spain", @"http://en.wikipedia.org/wiki/Spain"); AddDataPoint(scaleX, bar, 42, "France", @"http://en.wikipedia.org/wiki/France"); AddDataPoint(scaleX, bar, 56, "Germany", @"http://en.wikipedia.org/wiki/Germany"); AddDataPoint(scaleX, bar, 23, "Italy", @"http://en.wikipedia.org/wiki/Italy"); AddDataPoint(scaleX, bar, 47, "UK", @"http://en.wikipedia.org/wiki/UK"); AddDataPoint(scaleX, bar, 38, "Sweden", @"http://en.wikipedia.org/wiki/Sweden"); // add the index of the bar to highlight control.CustomData = 0; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.NevronMultiColor); styleSheet.Apply(bar); // configure toolbar control.Toolbar.Visible = true; control.Controller.SetActivePanel(chart); control.AutoUpdateCallback = new NAutoUpdateCallback(); //control.Controller.EnableAutoUpdate = true; NTrackballTool tbt = new NTrackballTool(); tbt.Exclusive = true; tbt.Enabled = true; control.Controller.Tools.Add(tbt); // add a data zoom tool NDataZoomTool dataZoomTool = new NDataZoomTool(); dataZoomTool.Exclusive = true; dataZoomTool.Enabled = false; control.Controller.Tools.Add(dataZoomTool); // add a data pan tool NDataPanTool dataPanTool = new NDataPanTool(); dataPanTool.Exclusive = true; dataPanTool.Enabled = false; control.Controller.Tools.Add(dataPanTool); // add a tooltip tool control.Controller.Tools.Add(new NTooltipTool()); // add a cursor change tool control.Controller.Tools.Add(new NCursorTool()); // add a browser redirect tool control.Controller.Tools.Add(new NBrowserRedirectTool()); control.Toolbar.Visible = true; control.Toolbar.Items.Add(new NToolbarButton(new NSaveStateAction())); control.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("CheckPDF", new NPdfImageFormat(), false, new NSize(600, 600), 300))); control.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("CheckPDF", new NSvgImageFormat(), false, new NSize(600, 600), 300))); control.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("CheckPDF", new NXamlImageFormat(), false, new NSize(600, 600), 300))); control.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("CheckPDF", new NBitmapImageFormat(), false, new NSize(600, 600), 300))); control.Toolbar.Items.Add(new NToolbarSeparator()); control.Toolbar.Items.Add(new NToolbarButton(new NTogglePanelSelectorToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleTrackballToolAction())); control.Toolbar.Items.Add(new NToolbarSeparator()); control.Toolbar.Items.Add(new NToolbarButton(new NToggleAutoUpdateAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleChart3DAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleChartLightingAction())); control.Toolbar.Items.Add(new NToolbarSeparator()); control.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleBrowserRedirectToolAction())); control.Toolbar.Items.Add(new NToolbarButton(new NToggleCursorToolAction())); }
void INIndicatorDragCallback.OnIndicatorValueChanged(NThinChartControl control, NGaugePanel gauge, NIndicator indicator, double oldValue, double newValue) { control.AddCustomClientCommand(newValue.ToString("00.00")); }
public override void Initialize(NThinChartControl control) { control.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = control.Labels.AddHeader("Data Pan Tool"); title.TextStyle.TextFormat = GraphicsCore.TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend control.Legends.Clear(); // setup chart NChart chart = control.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); scaleY.RoundToTickMax = false; scaleY.RoundToTickMin = false; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleX.RoundToTickMax = false; scaleX.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.Name = "Point1"; point.DataLabelStyle.Visible = false; point.FillStyle = new NColorFillStyle(Color.FromArgb(160, NevronColor1)); point.BorderStyle.Width = new NLength(0); point.Size = new NLength(2, NRelativeUnit.ParentPercentage); point.PointShape = PointShape.Ellipse; // instruct the point series to use custom X values point.UseXValues = true; // generate some random X values GenerateXYData(point); control.RecalcLayout(); chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); chart.Axis(StandardAxis.PrimaryY).PagingView.ZoomIn(new NRange1DD(-0.5, 0.5), 0.0001); // apply layout ApplyLayoutTemplate(0, control, chart, title, null); control.Controller.SetActivePanel(chart); control.ServerSettings.EnableTiledZoom = true; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true; NDataPanTool dataPanTool = new NDataPanTool(); control.Controller.Tools.Clear(); control.Controller.Tools.Add(dataPanTool); }
public override void Initialize(NThinChartControl control) { NBarSeries bar; control.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = control.Labels.AddHeader("Capturing Mouse Events"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // configure the legend NLegend legend = control.Legends[0]; legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Right); legend.FillStyle.SetTransparencyPercent(50); legend.Location = new NPointL(new NLength(98, NRelativeUnit.ParentPercentage), legend.Location.Y); // configure the chart NChart chart = control.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // create a bar series bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "My Bar Series"; bar.DataLabelStyle.Format = "<value>"; bar.AddDataPoint(new NDataPoint(10, "Ford", new NColorFillStyle(RandomColor()))); bar.AddDataPoint(new NDataPoint(20, "Toyota", new NColorFillStyle(RandomColor()))); bar.AddDataPoint(new NDataPoint(30, "VW", new NColorFillStyle(RandomColor()))); bar.AddDataPoint(new NDataPoint(25, "Mitsubishi", new NColorFillStyle(RandomColor()))); bar.AddDataPoint(new NDataPoint(29, "Jaguar", new NColorFillStyle(RandomColor()))); bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.BarShape = BarShape.SmoothEdgeBar; bar.DataLabelStyle.Visible = false; control.Controller.Tools.Add(new NClientMouseEventTool()); bar.InteractivityStyles.Clear(); for (int i = 0; i < bar.Values.Count; i++) { NInteractivityStyle interactivityStyle = new NInteractivityStyle(); string script = "alert(\"Mouse Event [Mouse Click]. Captured for bar [" + i.ToString() + "])\");"; interactivityStyle.ClientMouseEventAttribute.Click = script; bar.InteractivityStyles[i] = interactivityStyle; } }