예제 #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)
        {
            DonutChartData  data  = null;
            DonutChartStyle style = null;

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

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

            DA.SetData(0, chart);
        }
예제 #2
0
        /// <summary>
        ///     Donut Chart Style object.
        /// </summary>
        /// <param name="HoverColor">Hover over color.</param>
        /// <param name="Colors">List of optional colors for chart values.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of chart in pixels.</param>
        /// <param name="Labels">Boolean value that controls if Labels are displayed.</param>
        /// <param name="TotalLabel">Text appearing at center of the Donut chart.</param>
        /// <returns name="Style">Donut Chart Object.</returns>
        /// <search>donut, chart, style</search>
        public static DonutChartStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color HoverColor,
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width         = 400,
            bool Labels       = true,
            string TotalLabel = "TOTAL")
        {
            DonutChartStyle style = new DonutChartStyle();

            style.Width      = Width;
            style.HoverColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(HoverColor.Alpha, HoverColor.Red, HoverColor.Green, HoverColor.Blue));
            style.Labels     = Labels;
            style.TotalLabel = TotalLabel;
            style.Margins    = Margins;
            style.SizeX      = (int)Math.Ceiling(Width / 100d);
            style.SizeY      = (int)Math.Ceiling(Width / 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);
            Margins      margins    = new Margins();
            int          width      = 400;
            bool         labels     = true;
            string       totalLabel = "TOTAL";

            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 <bool>(5, ref labels);
            DA.GetData <string>(6, ref totalLabel);

            // create style
            DonutChartStyle style = new DonutChartStyle();

            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.HoverColor = ChartsUtilities.ColorToHexString(hoverColor);
            style.GridRow    = address.X;
            style.GridColumn = address.Y;
            style.Width      = width;
            style.Labels     = labels;
            style.TotalLabel = totalLabel;
            style.Margins    = margins;
            style.SizeX      = (int)Math.Ceiling(width / 100d);
            style.SizeY      = (int)Math.Ceiling(width / 100d);

            DA.SetData(0, style);
        }
예제 #4
0
 /// <summary>
 ///     Donut Chart object.
 /// </summary>
 /// <param name="Data">Donut Chart Data object.</param>
 /// <param name="Style">Donut Chart Style object.</param>
 /// <returns name="Chart">Donut Chart</returns>
 /// <search>donut chart, chart, donut</search>
 public static D3jsLib.DonutChart.DonutChart Chart(DonutChartData Data, DonutChartStyle Style)
 {
     D3jsLib.DonutChart.DonutChart chart = new D3jsLib.DonutChart.DonutChart(Data, Style);
     return(chart);
 }