Group: Forum Members
Last Active: 12 Years Ago
Posts: 5,
Visits: 1
|
Hi there I'm creating an application, using the diagrams of nevron, i'm using a nLibraryBrowser to add shapes and controls to a Drawing Document in a nDrawingView.
The idea is create a diagram using the nLibraryBrowse to drag and drop items to the nDrawingDocument, but I want to add a custom ChartDiagram. I'm using a NWinFormControlHostShape object to can add to the chart, however, when I drop the item into the ndrawingDocument it doesn't have series. I have made some similar with other control like comboboxes and it works.
The chart that I'm using, I have tested adding it into the ndrawing document and it works in the following way:
NWinFormControlHostShape chartsShape = new NWinFormControlHostShape(CreateChart()); nDrawingDocument1.ActiveLayer.AddChild(chartsShape);
This is part of my code, I hope you could help me, maybe I have to add something else to the NlibraryBrowser:
public Form1() { InitializeComponent(); nLibraryBrowser1.ClearBands();
NLibraryDocument library = new NLibraryDocument(); library.Info.Title = "testing";
//Rectangle Shape NBasicShapesFactory factory = new NBasicShapesFactory(nDrawingDocument1); NShape rectangle = factory.CreateShape((int)BasicShapes.Rectangle); rectangle.Width = 50; rectangle.Height = 50; library.AddChild(new NMaster(rectangle, NGraphicsUnit.Pixel, "Rectangle", "Rectangle Shape"));
//Chart NWinFormControlHostShape chartShape = new NWinFormControlHostShape(CreateChart()); library.AddChild(new NMaster(chartShape, NGraphicsUnit.Pixel, "Chart", "Custom Chart"));
//ComboBox NWinFormControlHostShape comboboxShape = new NWinFormControlHostShape(CreateComboBox()); library.AddChild(new NMaster(comboboxShape,NGraphicsUnit.Pixel, "Combobox", "Custom Combobox"));
nLibraryBrowser1.OpenLibraryGroup(library); nDrawingDocument1.RefreshAllViews(); }
private Nevron.Chart.WinForm.NChartControl CreateChart() { Nevron.Chart.WinForm.NChartControl ChartControl = new Nevron.Chart.WinForm.NChartControl();
Nevron.Chart.NBarSeries Bar; Nevron.Chart.NChart chart = ChartControl.Charts[0]; chart.Dock = DockStyle.Fill; chart.DisplayOnLegend.Visible = false;
Bar = new Nevron.Chart.NBarSeries(); Bar.BorderStyle.Color = Color.Red; Bar.Name = "BarSerieValues";
Random ale = new Random(); Bar.AddDataPoint(new NDataPoint(ale.Next(1, 100) * ale.Next(1, 10), "A")); Bar.AddDataPoint(new NDataPoint(ale.Next(1, 100) * ale.Next(1, 10), "B")); Bar.AddDataPoint(new NDataPoint(ale.Next(1, 100) * ale.Next(1, 10), "C")); Bar.AddDataPoint(new NDataPoint(ale.Next(1, 100) * ale.Next(1, 10), "D"));
chart.Series.Add(Bar);
ChartControl.Charts[0].Refresh(); ChartControl.Refresh(); ChartControl.Dock = DockStyle.Bottom;
return ChartControl; }
Regards, Hector
|