コード例 #1
0
        /// <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)
        {
            NormalizedStackedBarChartData  data  = null;
            NormalizedStackedBarChartStyle style = null;

            if (!DA.GetData <NormalizedStackedBarChartData>(0, ref data))
            {
                return;
            }
            if (!DA.GetData <NormalizedStackedBarChartStyle>(1, ref style))
            {
                return;
            }

            D3jsLib.NormalizedStackedBarChart.NormalizedStackedBarChart chart = new D3jsLib.NormalizedStackedBarChart.NormalizedStackedBarChart(data, style);

            DA.SetData(0, chart);
        }
コード例 #2
0
        /// <summary>
        ///    Normalized Stacked Bar Chart Style.
        /// </summary>
        /// <param name="BarHoverColor"></param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width"></param>
        /// <param name="Height"></param>
        /// <param name="YAxisLabel"></param>
        /// <param name="Colors"></param>
        /// <returns name="Style">Normalized Stacked Bar Chart Style</returns>
        /// <search>normalized, stacked, bar, chart, style</search>
        public static NormalizedStackedBarChartStyle 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"
            )
        {
            NormalizedStackedBarChartStyle style = new NormalizedStackedBarChartStyle();

            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);
        }
コード例 #3
0
        /// <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
            NormalizedStackedBarChartStyle style = new NormalizedStackedBarChartStyle();

            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 = new JavaScriptSerializer().Serialize(hexColors);
            }
            else
            {
                style.Colors = null;
            }

            style.BarHoverColor = ChartsUtilities.ColorToHexString(hoverColor);
            style.GridRow       = address.X;
            style.GridColumn    = address.Y;
            style.Width         = width;
            style.Height        = height;
            style.YAxisLabel    = yAxisLabel;
            style.Margins       = margins;
            style.SizeX         = (int)Math.Ceiling(width / 100d);
            style.SizeY         = (int)Math.Ceiling(height / 100d);

            DA.SetData(0, style);
        }
コード例 #4
0
 /// <summary>
 ///     New Normalized Stacked Bar Chart object.
 /// </summary>
 /// <param name="Data">Normalized Stacked Bar Chart Data.</param>
 /// <param name="Style">Normalized Stacked Bar Chart Style.</param>
 /// <returns name="Chart">Generated Bar Chart.</returns>
 /// <search>normalized, bar, chart, grouped</search>
 public static D3jsLib.NormalizedStackedBarChart.NormalizedStackedBarChart Chart(NormalizedStackedBarChartData Data, NormalizedStackedBarChartStyle Style)
 {
     D3jsLib.NormalizedStackedBarChart.NormalizedStackedBarChart chart = new D3jsLib.NormalizedStackedBarChart.NormalizedStackedBarChart(Data, Style);
     return(chart);
 }