/// <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       dotColor   = Color.FromArgb(50, 130, 190);
            GridAddress address    = new GridAddress(1, 1);
            Margins     margins    = new Margins();
            int         width      = 1000;
            int         height     = 500;
            string      yAxisLabel = "LabelY";
            string      xAxisLabel = "LabelX";

            DA.GetData <Color>(0, ref dotColor);
            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 <string>(6, ref xAxisLabel);

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

            style.DotColor   = dotColor;
            style.GridRow    = address.X;
            style.GridColumn = address.Y;
            style.Margins    = margins;
            style.Width      = width;
            style.Height     = height;
            style.YAxisLabel = yAxisLabel;
            style.XAxisLabel = xAxisLabel;

            DA.SetData(0, style);
        }
예제 #2
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 = sColor.FromArgb(DotColor.Alpha, DotColor.Red, DotColor.Green, DotColor.Blue);
            style.Margins = Margins;

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

            return style;
        }
        public XYPlotScatterStyleController(ScatterPlotStyle doc)
        {
            if (doc == null)
            {
                throw new ArgumentNullException("doc is null");
            }

            if (!InitializeDocument(doc))
            {
                throw new ApplicationException("Programming error");
            }
        }
        public bool InitializeDocument(params object[] args)
        {
            if (args.Length == 0 || !(args[0] is ScatterPlotStyle))
            {
                return(false);
            }

            bool isFirstTime = (null == _doc);

            _doc     = (ScatterPlotStyle)args[0];
            _tempDoc = _useDocumentCopy == UseDocument.Directly ? _doc : (ScatterPlotStyle)_doc.Clone();
            Initialize(isFirstTime);
            return(true);
        }
예제 #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)
        {
            ScatterPlotData  data  = null;
            ScatterPlotStyle style = null;

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

            d3ScatterPlot chart = new d3ScatterPlot(data, style);

            DA.SetData(0, chart);
        }
예제 #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("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);
        }
예제 #7
0
        /// <summary>
        ///     Scatter Plot Chart.
        /// </summary>
        /// <param name="Data">Scatter Plot Data.</param>
        /// <param name="Style">Scatter Plot Style.</param>
        /// <returns name="Chart">Scatter Plot Chart.</returns>
        /// <search>scatter plot, chart</search>
        public static d3ScatterPlot Chart(ScatterPlotData Data, ScatterPlotStyle Style)
        {
            d3ScatterPlot chart = new d3ScatterPlot(Data, Style);

            return(chart);
        }
예제 #8
0
        void InitializeStyles()
        {
            // Clear the previous controller cache
            _additionalPlotStyle = null;
            if (_combinedScatterLineGroupController != null)
            {
                _combinedScatterLineGroupController.ChildControlChanged -= EhView_ActiveChildControlChanged;
                _combinedScatterLineGroupController = null;
            }
            _styleControllerList.Clear();


            // start to create new controllers
            if (_tempdoc.Style.Count > 0)
            {
                bool addHelperStyle = NeedsHelperStyle();
                bool useCombinedTab = UseCombinedScatterLineGroupTab();


                if (useCombinedTab)
                {
                    List <ControlViewElement> combList = new List <ControlViewElement>();

                    // create the controllers
                    IMVCANController ct1 = GetStyleController(_tempdoc.Style[0]);
                    _styleControllerList.Add(ct1);


                    if (addHelperStyle)
                    {
                        IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing <IPlotArea>(_doc);
                        // add either line or scatter
                        if (_tempdoc.Style[0] is LinePlotStyle)
                        {
                            ScatterPlotStyle scatterStyle = new ScatterPlotStyle();
                            scatterStyle.ParentObject = _tempdoc.Style;
                            _tempdoc.Style.PrepareNewSubStyle(scatterStyle, layer, _doc.GetRangesAndPoints(layer));
                            _additionalPlotStyle = scatterStyle;
                            scatterStyle.Shape   = Altaxo.Graph.Gdi.Plot.Styles.XYPlotScatterStyles.Shape.NoSymbol;

                            _additionalPlotStyleController = GetStyleController(_additionalPlotStyle);
                            combList.Add(new ControlViewElement("Symbol", _additionalPlotStyleController));
                            combList.Add(new ControlViewElement("Line", ct1));
                        }
                        else
                        {
                            LinePlotStyle lineStyle = new LinePlotStyle();
                            lineStyle.ParentObject = _tempdoc.Style;
                            _tempdoc.Style.PrepareNewSubStyle(lineStyle, layer, _doc.GetRangesAndPoints(layer));
                            _additionalPlotStyle = lineStyle;
                            lineStyle.Connection = Altaxo.Graph.Gdi.Plot.Styles.XYPlotLineStyles.ConnectionStyle.NoLine;

                            _additionalPlotStyleController = GetStyleController(_additionalPlotStyle);
                            combList.Add(new ControlViewElement("Symbol", ct1));
                            combList.Add(new ControlViewElement("Line", _additionalPlotStyleController));
                        }
                    }
                    else // no helper style, i.e. second style is line style
                    {
                        // create the controllers
                        IMVCANController ct2 = GetStyleController(_tempdoc.Style[1]);
                        _styleControllerList.Add(ct2);
                        combList.Add(new ControlViewElement("Symbol", ct1));
                        combList.Add(new ControlViewElement("Line", ct2));
                    }

                    combList.Add(new ControlViewElement(string.Empty, this, this._plotGroupView));
                    _combinedScatterLineGroupController = new Common.MultiChildController(combList.ToArray(), true);
                    Current.Gui.FindAndAttachControlTo(_combinedScatterLineGroupController);
                    string title;
                    if (null != _additionalPlotStyle)
                    {
                        title = string.Format("#{0}:{1}", 1, Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[0].GetType()));
                    }
                    else
                    {
                        title = "#1&&2:Symbol&&Line";
                    }
                    AddTab(title, _combinedScatterLineGroupController, _combinedScatterLineGroupController.ViewObject);
                    _combinedScatterLineGroupController.ChildControlChanged += this.EhView_ActiveChildControlChanged;
                } // if use CombinedTab

                // now the remaining styles
                int start = useCombinedTab ? (addHelperStyle ? 1 : 2) : 0;
                for (int i = start; i < _tempdoc.Style.Count; i++)
                {
                    IMVCANController ctrl = GetStyleController(_tempdoc.Style[i]);
                    _styleControllerList.Add(ctrl);
                    string title = string.Format("#{0}:{1}", (i + 1), Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[i].GetType()));
                    AddTab(title, ctrl, ctrl != null ? ctrl.ViewObject : null);
                }
            }
            base.SetElements(false);
        }