/// <summary> /// /// </summary> private void UpdateLegendItems() { if (nChartControl1 == null) { return; } NLegend legend = nChartControl1.Legends[0]; legend.Data.Items.Clear(); Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = "Some very long text about mark shape [" + markShape.ToString() + "]"; licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); licd.TextFitMode = (LegendTextFitMode)TextFitModeComboBox.SelectedIndex; licd.MaxTextWidth = new NLength((float)MaximumLegendItemWidthUpDown.Value); legend.Data.Items.Add(licd); } nChartControl1.Refresh(); }
private void CreateCustomLegend3(NDockPanel container) { NLegend markShapesBackground = CreateLegend(container, "Mark Shapes (Margins, Background)"); Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = markShape.ToString(); licd.TextStyle.FillStyle = new NColorFillStyle(Color.White); licd.TextStyle.FontStyle.EmSize = new NLength(10 + i); licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(Color.White); licd.MarkBorderStyle.Width = new NLength(0); licd.MarkLineStyle.Width = new NLength(0); licd.BackgroundFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); markShapesBackground.Data.Items.Add(licd); } // increase teh margins around each cell markShapesBackground.Data.CellMargins = new NMarginsL(10, 10, 10, 10); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // confgigure chart nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Legend Item Text Fit Mode"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(0, 10, 0, 10); nChartControl1.Panels.Add(title); // configure the legend NLegend legend = new NLegend(); legend.Header.Text = "Maximum Legend Item Text Size"; legend.Mode = LegendMode.Manual; legend.Data.ExpandMode = LegendExpandMode.HorzWrap; legend.DockMode = PanelDockMode.Top; legend.Margins = new NMarginsL(20, 20, 20, 20); nChartControl1.Panels.Add(legend); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init controls if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumNames(LegendItemTextFitModeDropDownList, typeof(LegendTextFitMode)); WebExamplesUtilities.FillComboWithValues(LegendItemMaximumWidthDropDownList, 50, 150, 50); } // Update legend items Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = "Some very long text about mark shape [" + markShape.ToString() + "]"; licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); licd.TextFitMode = (LegendTextFitMode)LegendItemTextFitModeDropDownList.SelectedIndex; licd.MaxTextWidth = new NLength((float)(LegendItemMaximumWidthDropDownList.SelectedIndex + 1) * 50); legend.Data.Items.Add(licd); } }
private NLegendItemCellData CreateLegendItem(string text, Color color) { NLegendItemCellData ldi = new NLegendItemCellData(); ldi.Text = text; ldi.MarkFillStyle = new NColorFillStyle(color); ldi.MarkLineStyle.Width = new NLength(0); return(ldi); }
private void NChartControl1_Click(object sender, EventArgs e) { NPostbackEventArgs eventArgs = e as NPostbackEventArgs; object selectedObject = eventArgs.Id.FindInDocument(nChartControl1.Document); if (selectedObject is NDataPoint) { NDataPoint dataPoint = (NDataPoint)selectedObject; dataPoint[DataPointValue.FillStyle] = new NColorFillStyle(Color.Red); NSeries series = (NSeries)dataPoint.ParentNode; series.StoreDataPoint(dataPoint.IndexInSeries, dataPoint); return; } if (selectedObject is NLabel) { ((NLabel)selectedObject).TextStyle.FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NLegend) { ((NLegend)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NLegendItemCellData) { NLegendItemCellData licd = selectedObject as NLegendItemCellData; NLegend legend = nChartControl1.Legends[0]; SelectDataItem(legend.Data.Items.IndexOf(licd)); return; } if (selectedObject is NChartWall) { ((NChartWall)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NAxisStripe) { ((NAxisStripe)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NAxis) { NAxis axis = selectedObject as NAxis; NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)axis.ScaleConfigurator; scaleConfigurator.RulerStyle.BorderStyle.Color = Color.Red; scaleConfigurator.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Red); } }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // confgigure chart nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Legend Custom Items"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(0, 10, 0, 10); nChartControl1.Panels.Add(title); NDockPanel container = new NDockPanel(); container.DockMode = PanelDockMode.Fill; container.Margins = new NMarginsL(5, 5, 5, 5); container.PositionChildPanelsInContentBounds = true; nChartControl1.Panels.Add(container); { NLegend markShapesNoStroke = CreateLegend(container, "Mark Shapes, Margins, Background"); Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = markShape.ToString(); licd.TextStyle.FillStyle = new NColorFillStyle(Color.White); licd.TextStyle.FontStyle.EmSize = new NLength(8); licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(Color.White); licd.MarkBorderStyle.Width = new NLength(0); licd.MarkLineStyle.Width = new NLength(0); licd.BackgroundFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); markShapesNoStroke.Data.Items.Add(licd); } // increase teh margins around each cell markShapesNoStroke.Data.CellMargins = new NMarginsL(5, 5, 5, 5); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
private void AddCustomLegendMark_Click(object sender, System.EventArgs e) { NLegendItemCellData legendDataItem = new NLegendItemCellData(); legendDataItem.Text = "Data item " + CustomLegendMarksComboBox.Items.Count.ToString(); m_Legend.Data.Items.Add(legendDataItem); CustomLegendMarksComboBox.Items.Add(legendDataItem.Text); CustomLegendMarksComboBox.SelectedIndex = CustomLegendMarksComboBox.Items.Count - 1; LegendItemPropertyGrid.Enabled = true; nChartControl1.Refresh(); }
private void CreateCustomLegend1(NDockPanel container) { NLegend markShapesLegend = CreateLegend(container, "Mark Shapes"); Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = markShape.ToString(); licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); markShapesLegend.Data.Items.Add(licd); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FilterDropDownList.Items.Add("More"); FilterDropDownList.Items.Add("Less"); FilterDropDownList.Items.Add("Equal"); FilterDropDownList.Items.Add("More Or Equal"); FilterDropDownList.Items.Add("Less Or Equal"); FilterDropDownList.Items.Add("Not Equal"); FilterDropDownList.SelectedIndex = 0; ValueTextBox.Text = "50"; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Filtering Data"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108)); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(85, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); Random rnd = new Random(0); NBarSeries nBar = (NBarSeries)chart.Series.Add(SeriesType.Bar); nBar.DataLabelStyle.Format = "<value>"; nBar.Values.FillRandom(rnd, 10); // configure the legend NLegend legend = nChartControl1.Legends[0]; legend.Mode = LegendMode.Manual; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; NLegendItemCellData item = new NLegendItemCellData("Filtered Data Points", LegendMarkShape.Rectangle, new NStrokeStyle(1, Color.Black), new NColorFillStyle(Color.Red), new NShadowStyle(), new NTextStyle()); legend.Data.Items.Add(item); item = new NLegendItemCellData("Series Data Points", LegendMarkShape.Rectangle, new NStrokeStyle(1, Color.Black), (NFillStyle)nBar.FillStyle.Clone(), new NShadowStyle(), new NTextStyle()); legend.Data.Items.Add(item); Filter(nBar); }
protected void Page_Load(object sender, EventArgs e) { // set a chart title if (!IsPostBack) { SearchForDropDownList.Items.Add("Max value"); SearchForDropDownList.Items.Add("Min value"); SearchForDropDownList.Items.Add("Custom value"); SearchForDropDownList.Items.Add("Custom string"); SearchForDropDownList.SelectedIndex = 0; CustomValueTextBox.Text = "20"; CustomStringTextBox.Text = "Bar 5"; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Finding Data"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108)); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // configure the chart NChart nChart = nChartControl1.Charts[0]; nChart.BoundsMode = BoundsMode.Stretch; nChart.Axis(StandardAxis.Depth).Visible = false; nChart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); nChart.Size = new NSizeL( new NLength(85, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); NBarSeries nBar = (NBarSeries)nChart.Series.Add(SeriesType.Bar); nBar.DataLabelStyle.Format = "<label>"; nBar.Values.Add(10); nBar.Values.Add(20); nBar.Values.Add(15); nBar.Values.Add(44); nBar.Values.Add(87); nBar.Values.Add(33); nBar.Values.Add(56); for (int i = 0; i < 7; i++) { nBar.Labels.Add("Bar " + (i + 1)); } FindAndHighlightDataPoints(nBar); // configure the legend NLegend legend = nChartControl1.Legends[0]; legend.Mode = LegendMode.Manual; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; NLegendItemCellData item = new NLegendItemCellData("Found Data Point", LegendMarkShape.Rectangle, new NStrokeStyle(1, Color.Black), new NColorFillStyle(Color.Red), new NShadowStyle(), new NTextStyle()); legend.Data.Items.Add(item); item = new NLegendItemCellData("Series Data Points", LegendMarkShape.Rectangle, new NStrokeStyle(1, Color.Black), (NFillStyle)nBar.FillStyle.Clone(), new NShadowStyle(), new NTextStyle()); legend.Data.Items.Add(item); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LegendModeDropDownList.Items.Add("Disabled"); LegendModeDropDownList.Items.Add("Automatic"); LegendModeDropDownList.Items.Add("Manual"); LegendModeDropDownList.SelectedIndex = 1; PredefinedStyleDropDownList.Items.Add("Top"); PredefinedStyleDropDownList.Items.Add("Bottom"); PredefinedStyleDropDownList.Items.Add("Left"); PredefinedStyleDropDownList.Items.Add("Right"); PredefinedStyleDropDownList.Items.Add("Top right"); PredefinedStyleDropDownList.Items.Add("Top left"); PredefinedStyleDropDownList.SelectedIndex = 4; ExpandModeDropDownList.Items.Add("Rows only"); ExpandModeDropDownList.Items.Add("Cols only"); ExpandModeDropDownList.Items.Add("Rows fixed"); ExpandModeDropDownList.Items.Add("Cols fixed"); ExpandModeDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(ManualItemsDropDownList, 1, 20, 1); ManualItemsDropDownList.SelectedIndex = 5; WebExamplesUtilities.FillComboWithValues(RowCountDropDownList, 1, 10, 1); RowCountDropDownList.SelectedIndex = 5; WebExamplesUtilities.FillComboWithValues(ColCountDropDownList, 1, 10, 1); ColCountDropDownList.SelectedIndex = 5; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Settings.JitteringSteps = 4; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Legend General"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup the chart NChart chart = nChartControl1.Charts[0]; NBarSeries barSeries = (NBarSeries)chart.Series.Add(SeriesType.Bar); barSeries.DataLabelStyle.Visible = false; barSeries.Legend.Mode = SeriesLegendMode.DataPoints; barSeries.Legend.Format = "<label> <percent>"; barSeries.Values.FillRandom(Random, numberOfDataPoints); for (int i = 0; i < numberOfDataPoints; i++) { barSeries.Labels.Add("Item " + i.ToString()); } // setup the legend m_Legend = nChartControl1.Legends[0]; m_Legend.FillStyle.SetTransparencyPercent(50); m_Legend.Mode = ((LegendMode)LegendModeDropDownList.SelectedIndex); if (m_Legend.Mode != LegendMode.Manual) { ManualItemsDropDownList.Enabled = false; } else { NLegendItemCellData legendItemCellData; ManualItemsDropDownList.Enabled = true; // fill some manual legend data items. int manualItemCount = ManualItemsDropDownList.SelectedIndex + 1; for (int i = 0; i < manualItemCount; i++) { legendItemCellData = new NLegendItemCellData(); legendItemCellData.Text = "Manual item " + i.ToString(); legendItemCellData.MarkShape = LegendMarkShape.Rectangle; Color itemColor = WebExamplesUtilities.RandomColor(); legendItemCellData.MarkFillStyle = new NColorFillStyle(itemColor); m_Legend.Data.Items.Add(legendItemCellData); } } m_Legend.Header.Text = LegendHeaderTextBox.Text; m_Legend.Footer.Text = LegendFooterTextBox.Text; m_Legend.SetPredefinedLegendStyle((PredefinedLegendStyle)PredefinedStyleDropDownList.SelectedIndex); m_Legend.Data.ExpandMode = (LegendExpandMode)ExpandModeDropDownList.SelectedIndex; if (m_Legend.Data.ExpandMode == LegendExpandMode.ColsOnly || m_Legend.Data.ExpandMode == LegendExpandMode.RowsOnly) { RowCountDropDownList.Enabled = false; ColCountDropDownList.Enabled = false; } else if (m_Legend.Data.ExpandMode == LegendExpandMode.RowsFixed) { RowCountDropDownList.Enabled = true; ColCountDropDownList.Enabled = false; m_Legend.Data.RowCount = RowCountDropDownList.SelectedIndex + 1; } else if (m_Legend.Data.ExpandMode == LegendExpandMode.ColsFixed) { RowCountDropDownList.Enabled = false; ColCountDropDownList.Enabled = true; m_Legend.Data.ColCount = ColCountDropDownList.SelectedIndex + 1; } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); }