/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { GroupedBarChartData data = null; GroupedBarChartStyle style = null; if (!DA.GetData <GroupedBarChartData>(0, ref data)) { return; } if (!DA.GetData <GroupedBarChartStyle>(1, ref style)) { return; } D3jsLib.GroupedBarChart.GroupedBarChart chart = new D3jsLib.GroupedBarChart.GroupedBarChart(data, style); DA.SetData(0, chart); }
/// <summary> /// Grouped Bar Chart Style. /// </summary> /// <param name="BarHoverColor">Hover over color.</param> /// <param name="Address">Grid Coordinates</param> /// <param name="Margins">Margins in pixels.</param> /// <param name="Width">Width in pixels.</param> /// <param name="Height">Height in pixels.</param> /// <param name="YAxisLabel">Label for Y-Axis.</param> /// <param name="Colors">Optional list of colors for each group.</param> /// <returns name="Style">Bar Chart Style object.</returns> /// <search>grouped, bar, chart, style</search> public static GroupedBarChartStyle Style( [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor, [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors, [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address, [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins, int Width = 1000, int Height = 500, string YAxisLabel = "Label" ) { GroupedBarChartStyle style = new GroupedBarChartStyle(); style.Width = Width; style.Height = Height; style.YAxisLabel = YAxisLabel; style.BarHoverColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue)); style.Margins = Margins; style.SizeX = (int)Math.Ceiling(Width / 100d); style.SizeY = (int)Math.Ceiling(Height / 100d); if (Colors != null) { List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList(); style.Colors = new JavaScriptSerializer().Serialize(hexColors); } else { style.Colors = null; } if (Address != null) { style.GridRow = Address.X; style.GridColumn = Address.Y; } else { style.GridRow = 1; style.GridColumn = 1; } return(style); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Color hoverColor = Color.FromArgb(255, 0, 0); List <Color> colors = new List <Color>(); GridAddress address = new GridAddress(1, 1); int width = 1000; int height = 500; string yAxisLabel = "Label"; Margins margins = new Margins(); DA.GetData <Color>(0, ref hoverColor); DA.GetData <GridAddress>(2, ref address); DA.GetData <Margins>(3, ref margins); DA.GetData <int>(4, ref width); DA.GetData <int>(5, ref height); DA.GetData <string>(6, ref yAxisLabel); // create style GroupedBarChartStyle style = new GroupedBarChartStyle(); if (DA.GetDataList <Color>(1, colors)) { List <string> hexColors = colors.Select(x => ChartsUtilities.ColorToHexString(Color.FromArgb(x.A, x.R, x.G, x.B))).ToList(); style.Colors = hexColors; } else { style.Colors = null; } style.BarHoverColor = hoverColor; style.GridRow = address.X; style.GridColumn = address.Y; style.Width = width; style.Height = height; style.YAxisLabel = yAxisLabel; style.Margins = margins; DA.SetData(0, style); }
/// <summary> /// New Grouped Bar Chart object. /// </summary> /// <param name="Data">Bar Chart Data.</param> /// <param name="Style">Bar Chart Style.</param> /// <returns name="Chart">Generated Bar Chart.</returns> /// <search>bar, chart, grouped</search> public static D3jsLib.GroupedBarChart.GroupedBarChart Chart(GroupedBarChartData Data, GroupedBarChartStyle Style) { D3jsLib.GroupedBarChart.GroupedBarChart chart = new D3jsLib.GroupedBarChart.GroupedBarChart(Data, Style); return(chart); }