public override void CreateChartModel(int counter)
        {
            NormalizedStackedBarChartModel model = new NormalizedStackedBarChartModel();

            model.Width      = this.Style.Width;
            model.Height     = this.Style.Height;
            model.YAxisLabel = this.Style.YAxisLabel;
            model.BarHover   = ChartsUtilities.ColorToHexString(this.Style.BarHoverColor);
            model.DivId      = "div" + counter.ToString();
            model.Margins    = this.Style.Margins;

            // set grid address
            model.GridRow    = this.Style.GridRow;
            model.GridColumn = this.Style.GridColumn;

            // always round up for the grid size so chart is smaller then container
            model.SizeX = (int)System.Math.Ceiling(this.Style.Width / 100d);
            model.SizeY = (int)System.Math.Ceiling(this.Style.Height / 100d);

            if (this.Style.Colors != null)
            {
                string domainColors = new JavaScriptSerializer().Serialize(this.Style.Colors);
                model.DomainColors = domainColors;
                model.Colors       = true;
            }
            else
            {
                model.Colors = false;
            }

            model.Data = this.Data.ToJsonString();

            this.ChartModel = model;
        }
Esempio n. 2
0
        /// <summary>
        ///     Area Chart Style object.
        /// </summary>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Marings in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="YAxisLabel">Text used to label Y Axis.</param>
        /// <param name="AreaColor">Color for Area Chart fill.</param>
        /// <param name="TickMarksX">Approximate number of tick marks on X Axis.</param>
        /// <returns name="Style">Area Chart Style.</returns>
        /// <search>area, chart, style</search>
        public static AreaChartStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color AreaColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label",
            int TickMarksX    = 10)
        {
            AreaChartStyle style = new AreaChartStyle();

            style.Width      = Width;
            style.Height     = Height;
            style.YAxisLabel = YAxisLabel;
            style.AreaColor  = ChartsUtilities.ColorToHexString(sColor.FromArgb(AreaColor.Alpha, AreaColor.Red, AreaColor.Green, AreaColor.Blue));
            style.TickMarksX = TickMarksX;
            style.Margins    = Margins;
            style.SizeX      = (int)Math.Ceiling(Width / 100d);
            style.SizeY      = (int)Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 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       lineColor  = Color.FromArgb(50, 130, 190);
            GridAddress address    = new GridAddress(1, 1);
            int         width      = 1000;
            int         height     = 500;
            string      yAxisLabel = "Label";
            int         tickMarks  = 2;
            Margins     margins    = new Margins();

            DA.GetData <Color>(0, ref lineColor);
            DA.GetData <GridAddress>(1, ref address);
            DA.GetData <Margins>(2, ref margins);
            DA.GetData <int>(3, ref width);
            DA.GetData <int>(4, ref height);
            DA.GetData <string>(5, ref yAxisLabel);
            DA.GetData <int>(6, ref tickMarks);

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

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

            DA.SetData(0, style);
        }
        /// <summary>
        ///     Style
        /// </summary>
        /// <param name="Colors">List of Colors.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <returns name="Style">Style</returns>
        public static ScatterPlotMatrixStyle Style(
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width = 1000
            )
        {
            ScatterPlotMatrixStyle style = new ScatterPlotMatrixStyle();

            style.Width = Width;

            if (Colors != null)
            {
                List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList();
                style.Colors = 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);
        }
Esempio n. 5
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       lineColor = Color.FromArgb(50, 130, 190);
            GridAddress address   = new GridAddress(1, 1);
            Margins     margins   = new Margins();
            int         width     = 1000;
            int         height    = 500;

            DA.GetData <Color>(0, ref lineColor);
            DA.GetData <GridAddress>(1, ref address);
            DA.GetData <Margins>(2, ref margins);
            DA.GetData <int>(3, ref width);
            DA.GetData <int>(4, ref height);

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

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

            DA.SetData(0, style);
        }
Esempio n. 6
0
        /// <summary>
        ///     Scatter Plot Style.
        /// </summary>
        /// <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 displayed for Y Axis.</param>
        /// <param name="XAxisLabel">Label displayed for X Axis.</param>
        /// <param name="DotColor">Color of Scatter Plot dot.</param>
        /// <returns name="Style">Scatter Plot Style.</returns>
        /// <search>style, scatter plot</search>
        public static ScatterPlotStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,100,100,100)")] DSCore.Color DotColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label",
            string XAxisLabel = "Label")
        {
            ScatterPlotStyle style = new ScatterPlotStyle();

            style.Width      = Width;
            style.Height     = Height;
            style.YAxisLabel = YAxisLabel;
            style.XAxisLabel = XAxisLabel;
            style.DotColor   = ChartsUtilities.ColorToHexString(sColor.FromArgb(DotColor.Alpha, DotColor.Red, DotColor.Green, DotColor.Blue));
            style.Margins    = Margins;
            style.SizeX      = (int)Math.Ceiling(Width / 100d);
            style.SizeY      = (int)Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 7
0
        /// <summary>
        ///     Parallel Coordinates Style object.
        /// </summary>
        /// <param name="LineColor">Color of the selected Lines/Values.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the Chart in pixels.</param>
        /// <param name="Height">Height of the Chart in pixels.</param>
        /// <returns name="Style">Parallel Coordinates Style.</returns>
        /// <search>parallel, coordinates, style</search>
        public static ParallelCoordinatesStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color LineColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width  = 1000,
            int Height = 500)
        {
            ParallelCoordinatesStyle style = new ParallelCoordinatesStyle();

            style.Width     = Width;
            style.Height    = Height;
            style.LineColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(LineColor.Alpha, LineColor.Red, LineColor.Green, LineColor.Blue));
            style.Margins   = Margins;
            style.SizeX     = (int)Math.Ceiling(Width / 100d);
            style.SizeY     = (int)Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 8
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)
        {
            List <Color> colors  = new List <Color>();
            GridAddress  address = new GridAddress(1, 1);
            int          width   = 1000;

            DA.GetData <GridAddress>(1, ref address);
            DA.GetData <int>(2, ref width);

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

            if (DA.GetDataList <Color>(0, 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.GridRow    = address.X;
            style.GridColumn = address.Y;
            style.Width      = width;

            DA.SetData(0, style);
        }
Esempio n. 9
0
        /// <summary>
        ///     Create Text Style
        /// </summary>
        /// <param name="FontColor">Color</param>
        /// <param name="Address">Grid Coordinates</param>
        /// <param name="Width">Width of Grid container.</param>
        /// <param name="Height">Height of Grid Container.</param>
        /// <param name="FontSize">Size</param>
        /// <param name="FontWeight">Weight</param>
        /// <param name="FontStyle">Style</param>
        /// <param name="FontTransform">Transform</param>
        /// <returns name="Style">Style for the Text Note object</returns>
        public static TextStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,0,0,0)")] Color FontColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width            = 200,
            int Height           = 100,
            double FontSize      = 20.0,
            string FontWeight    = "normal",
            string FontStyle     = "normal",
            string FontTransform = "none")
        {
            TextStyle style = new TextStyle();

            style.FontSize      = FontSize;
            style.FontColor     = ChartsUtilities.ColorToHexString(sColor.FromArgb(FontColor.Alpha, FontColor.Red, FontColor.Green, FontColor.Blue));
            style.FontWeight    = FontWeight;
            style.FontStyle     = FontStyle;
            style.FontTransform = FontTransform;
            style.Width         = Width;
            style.Height        = Height;
            style.SizeX         = (int)System.Math.Ceiling(Width / 100d);
            style.SizeY         = (int)System.Math.Ceiling(Height / 100d);

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 10
0
        public override void CreateChartModel(int counter)
        {
            ScatterPlotModel model = new ScatterPlotModel();

            model.Width      = this.Style.Width;
            model.Height     = this.Style.Height;
            model.YAxisLabel = this.Style.YAxisLabel;
            model.XAxisLabel = this.Style.XAxisLabel;
            model.DotColor   = ChartsUtilities.ColorToHexString(this.Style.DotColor);
            model.DivId      = "div" + counter.ToString();
            model.Margins    = this.Style.Margins;

            // set grid address
            model.GridRow    = this.Style.GridRow;
            model.GridColumn = this.Style.GridColumn;

            // always round up for the grid size so chart is smaller then container
            model.SizeX = (int)System.Math.Ceiling(this.Style.Width / 100d);
            model.SizeY = (int)System.Math.Ceiling(this.Style.Height / 100d);

            if (this.Data.DomainX == null)
            {
                model.DomainX = false;
            }
            else
            {
                model.DomainX  = true;
                model.DomainXA = this.Data.DomainX.A.ToString();
                model.DomainXB = this.Data.DomainX.B.ToString();
            }

            if (this.Data.DomainY == null)
            {
                model.DomainY = false;
            }
            else
            {
                model.DomainY  = true;
                model.DomainYA = this.Data.DomainY.A.ToString();
                model.DomainYB = this.Data.DomainY.B.ToString();
            }

            // serialize C# Array into JS Array
            var    serializer = new JavaScriptSerializer();
            string jsData     = serializer.Serialize(this.Data.Data);

            model.Data = jsData;

            this.ChartModel = model;
        }
Esempio n. 11
0
        /// <summary>
        ///     Legend Style
        /// </summary>
        /// <param name="Colors">List of colors for each rectangle.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <param name="Height">Height in pixels.</param>
        /// <param name="Title">Title below legend.</param>
        /// <param name="RectangleSize">Rectangle size in pixels.</param>
        /// <returns name="Style">Style</returns>
        public static LegendStyle Style(
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width         = 200,
            int Height        = 400,
            string Title      = "Title",
            int RectangleSize = 20
            )
        {
            LegendStyle style = new LegendStyle();

            style.Width         = Width;
            style.Height        = Height;
            style.Title         = Title;
            style.RectangleSize = RectangleSize;

            if (Colors != null)
            {
                List <string> hexColors = new List <string>();
                foreach (DSCore.Color color in Colors)
                {
                    string col = ChartsUtilities.ColorToHexString(sColor.FromArgb(color.Alpha, color.Red, color.Green, color.Blue));
                    hexColors.Add(col);
                }
                style.Colors = 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);
        }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
        /// <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
            StackedBarChartStyle style = new StackedBarChartStyle();

            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);
        }
Esempio n. 16
0
        /// <summary>
        ///     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">Stacked Bar Chart Style</returns>
        /// <search>stacked, bar, chart, style</search>
        public static StackedBarChartStyle 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(20,40,20,40)")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label"
            )
        {
            StackedBarChartStyle style = new StackedBarChartStyle();

            style.Width         = Width;
            style.Height        = Height;
            style.YAxisLabel    = YAxisLabel;
            style.BarHoverColor = sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue);
            style.Margins       = Margins;

            if (Colors != null)
            {
                List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList();
                style.Colors = 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);
        }
Esempio n. 17
0
        /// <summary>
        ///     Legend Style
        /// </summary>
        /// <param name="Colors">List of colors for each rectangle.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Width">Width in pixels.</param>
        /// <param name="Height">Height in pixels.</param>
        /// <param name="Title">Title below legend.</param>
        /// <param name="RectangleSize">Rectangle size in pixels.</param>
        /// <returns name="Style">Style</returns>
        public static LegendStyle Style(
            [DefaultArgumentAttribute("Charts.MiscNodes.GetNull()")] List <DSCore.Color> Colors,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            int Width         = 200,
            int Height        = 400,
            string Title      = "Title",
            int RectangleSize = 20
            )
        {
            LegendStyle style = new LegendStyle();

            style.Width         = Width;
            style.Height        = Height;
            style.Title         = Title;
            style.RectangleSize = RectangleSize;
            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);
        }
Esempio n. 18
0
        public override void CreateChartModel(int counter)
        {
            BarChartModel model = new BarChartModel();

            model.Width         = this.Style.Width;
            model.Height        = this.Style.Height;
            model.YAxisLabel    = this.Style.YAxisLabel;
            model.TickMarksX    = this.Style.TickMarksX.ToString();
            model.BarFill       = ChartsUtilities.ColorToHexString(this.Style.BarColor);
            model.BarHover      = ChartsUtilities.ColorToHexString(this.Style.BarHoverColor);
            model.DivId         = "div" + counter.ToString();
            model.xTextRotation = this.Style.xTextRotation;
            model.Margins       = this.Style.Margins;

            // set grid address
            model.GridRow    = this.Style.GridRow;
            model.GridColumn = this.Style.GridColumn;

            // always round up for the grid size so chart is smaller then container
            model.SizeX = (int)System.Math.Ceiling(this.Style.Width / 100d);
            model.SizeY = (int)System.Math.Ceiling(this.Style.Height / 100d);

            if (this.Data.Domain == null)
            {
                model.Domain = false;
            }
            else
            {
                model.Domain  = true;
                model.DomainA = this.Data.Domain.A.ToString();
                model.DomainB = this.Data.Domain.B.ToString();
            }

            // serialize C# Array into JS Array
            var    serializer = new JavaScriptSerializer();
            string jsData     = serializer.Serialize(this.Data.Data);

            model.Data = jsData;

            this.ChartModel = model;
        }
Esempio n. 19
0
        public override void CreateChartModel(int counter)
        {
            ParallelCoordinatesModel model = new ParallelCoordinatesModel();

            model.Width     = this.Style.Width;
            model.Height    = this.Style.Height;
            model.LineColor = ChartsUtilities.ColorToHexString(this.Style.LineColor);
            model.Data      = this.Data.ToJsonString();
            model.DivId     = "div" + counter.ToString();
            model.Margins   = this.Style.Margins;

            // set grid address
            model.GridRow    = this.Style.GridRow;
            model.GridColumn = this.Style.GridColumn;

            // always round up for the grid size so chart is smaller then container
            model.SizeX = (int)System.Math.Ceiling(this.Style.Width / 100d);
            model.SizeY = (int)System.Math.Ceiling(this.Style.Height / 100d);

            this.ChartModel = model;
        }
Esempio n. 20
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Color       barColor   = Color.FromArgb(50, 130, 190);
            Color       hoverColor = Color.FromArgb(255, 0, 0);
            GridAddress address    = new GridAddress(1, 1);
            int         width      = 1000;
            int         height     = 500;
            string      yAxisLabel = "Label";
            int         tickMarks  = 2;
            bool        xRotation  = false;
            Margins     margins    = new Margins();

            DA.GetData <Color>(0, ref barColor);
            DA.GetData <Color>(1, 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);
            DA.GetData <int>(7, ref tickMarks);
            DA.GetData <bool>(8, ref xRotation);

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

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

            DA.SetData(0, style);
        }
Esempio n. 21
0
        /// <summary>
        ///     Bar Chart Style object.
        /// </summary>
        /// <param name="BarColor">Fill color for bars.</param>
        /// <param name="BarHoverColor">Fill color when hovered over.</param>
        /// <param name="Address">Grid Coordinates.</param>
        /// <param name="Margins">Margins in pixels.</param>
        /// <param name="Width">Width of the entire chart in pixels.</param>
        /// <param name="Height">Height of the entire chart in pixels.</param>
        /// <param name="YAxisLabel">Text displayed in top-left corner of chart.</param>
        /// <param name="TickMarksX">Approximate number of tick mark values for X Axis.</param>
        /// <param name="xTextRotation">Indicates if labels along x-axis are rotated.</param>
        /// <param name="Labels">Indicates if labels with actual bar values appear above each bar.</param>
        /// <returns name="Style">Bar Chart Style.</returns>
        /// <search>bar, chart, style</search>
        public static BarStyle Style(
            [DefaultArgument("DSCore.Color.ByARGB(1,50,130,190)")] DSCore.Color BarColor,
            [DefaultArgument("DSCore.Color.ByARGB(1,255,0,0)")] DSCore.Color BarHoverColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins(20,40,20,40)")] Margins Margins,
            int Width          = 1000,
            int Height         = 500,
            string YAxisLabel  = "Label",
            int TickMarksX     = 10,
            bool xTextRotation = false,
            bool Labels        = false)
        {
            BarStyle style = new BarStyle();

            style.BarColor      = ChartsUtilities.ColorToHexString(sColor.FromArgb(BarColor.Alpha, BarColor.Red, BarColor.Green, BarColor.Blue));
            style.BarHoverColor = ChartsUtilities.ColorToHexString(sColor.FromArgb(BarHoverColor.Alpha, BarHoverColor.Red, BarHoverColor.Green, BarHoverColor.Blue));
            style.Width         = Width;
            style.Height        = Height;
            style.YAxisLabel    = YAxisLabel;
            style.TickMarksX    = TickMarksX;
            style.xTextRotation = xTextRotation;
            style.Margins       = Margins;
            style.SizeX         = (int)Math.Ceiling(Width / 100d);
            style.SizeY         = (int)Math.Ceiling(Height / 100d);
            style.Labels        = Labels;

            if (Address != null)
            {
                style.GridRow    = Address.X;
                style.GridColumn = Address.Y;
            }
            else
            {
                style.GridRow    = 1;
                style.GridColumn = 1;
            }

            return(style);
        }
Esempio n. 22
0
        public override void CreateChartModel(int counter)
        {
            DonutChartModel model = new DonutChartModel();

            model.Width      = this.Style.Width;
            model.HoverColor = ChartsUtilities.ColorToHexString(this.Style.HoverColor);
            model.Labels     = this.Style.Labels;
            model.DivId      = "div" + counter.ToString();
            model.TotalLabel = this.Style.TotalLabel;
            model.Margins    = this.Style.Margins;

            // set grid address
            model.GridRow    = this.Style.GridRow;
            model.GridColumn = this.Style.GridColumn;

            // always round up for the grid size so chart is smaller then container
            model.SizeX = (int)System.Math.Ceiling(this.Style.Width / 100d);
            model.SizeY = (int)System.Math.Ceiling(this.Style.Width / 100d);

            if (this.Style.Colors != null)
            {
                string domainColors = new JavaScriptSerializer().Serialize(this.Style.Colors);
                model.DomainColors = domainColors;
                model.Colors       = true;
            }
            else
            {
                model.Colors = false;
            }

            // serialize C# Array into JS Array
            var    serializer = new JavaScriptSerializer();
            string jsData     = serializer.Serialize(this.Data.Data);

            model.Data = jsData;

            this.ChartModel = model;
        }
Esempio n. 23
0
        /// <summary>
        ///     Pie Chart Style
        /// </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>
        /// <returns name="Style">Pie Chart Style object.</returns>
        public static PieChartStyle 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)
        {
            PieChartStyle style = new PieChartStyle();

            style.Width      = Width;
            style.HoverColor = sColor.FromArgb(HoverColor.Alpha, HoverColor.Red, HoverColor.Green, HoverColor.Blue);
            style.Labels     = Labels;
            style.Margins    = Margins;

            if (Colors != null)
            {
                List <string> hexColors = Colors.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList();
                style.Colors = 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);
        }
Esempio n. 24
0
        /// <summary>
        ///     Scatter Plot Style.
        /// </summary>
        /// <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 displayed for Y Axis.</param>
        /// <param name="XAxisLabel">Label displayed for X Axis.</param>
        /// <param name="DotColor">Color of Scatter Plot dot.</param>
        /// <returns name="Style">Scatter Plot Style.</returns>
        /// <search>style, scatter plot</search>
        public static ScatterPlotStyle Style(
            [DefaultArgument("Charts.MiscNodes.GetColorList()")] List <DSCore.Color> DotColor,
            [DefaultArgument("Charts.MiscNodes.GetNull()")] GridAddress Address,
            [DefaultArgument("Charts.MiscNodes.Margins()")] Margins Margins,
            int Width         = 1000,
            int Height        = 500,
            string YAxisLabel = "Label",
            string XAxisLabel = "Label")
        {
            ScatterPlotStyle style = new ScatterPlotStyle();

            style.Width      = Width;
            style.Height     = Height;
            style.YAxisLabel = YAxisLabel;
            style.XAxisLabel = XAxisLabel;

            List <string> hexColors = DotColor.Select(x => ChartsUtilities.ColorToHexString(sColor.FromArgb(x.Alpha, x.Red, x.Green, x.Blue))).ToList();

            style.DotColor = new JavaScriptSerializer().Serialize(hexColors);

            style.Margins = Margins;
            style.SizeX   = (int)Math.Ceiling(Width / 100d);
            style.SizeY   = (int)Math.Ceiling(Height / 100d);

            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);
            Margins      margins    = new Margins();
            int          width      = 400;
            bool         labels     = true;

            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);

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

            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.HoverColor = hoverColor;
            style.GridRow    = address.X;
            style.GridColumn = address.Y;
            style.Width      = width;
            style.Labels     = labels;
            style.Margins    = margins;

            DA.SetData(0, style);
        }
Esempio n. 26
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       fontColor     = Color.FromArgb(0, 0, 0);
            GridAddress address       = new GridAddress(1, 1);
            int         width         = 200;
            int         height        = 100;
            double      fontSize      = 20.0;
            string      fontWeight    = "1";
            string      fontStyle     = "1";
            string      fontTransform = "1";

            DA.GetData <Color>(0, ref fontColor);
            DA.GetData <GridAddress>(1, ref address);
            DA.GetData <int>(2, ref width);
            DA.GetData <int>(3, ref height);
            DA.GetData <double>(4, ref fontSize);
            DA.GetData <string>(5, ref fontWeight);
            DA.GetData <string>(6, ref fontStyle);
            DA.GetData <string>(7, ref fontTransform);

            TextStyle style = new TextStyle();

            style.FontSize      = fontSize;
            style.FontColor     = ChartsUtilities.ColorToHexString(fontColor);
            style.FontWeight    = ((D3jsLib.Text.FontWeights) int.Parse(fontWeight)).ToString();
            style.FontStyle     = ((D3jsLib.Text.FontStyle) int.Parse(fontStyle)).ToString();
            style.FontTransform = ((D3jsLib.Text.FontTransform) int.Parse(fontTransform)).ToString();
            style.Width         = width;
            style.Height        = height;
            style.GridRow       = address.X;
            style.GridColumn    = address.Y;
            style.SizeX         = (int)Math.Ceiling(width / 100d);
            style.SizeY         = (int)Math.Ceiling(height / 100d);

            DA.SetData(0, style);
        }