Пример #1
0
        /// <summary>
        ///   加入 Series 資料來源
        /// </summary>
        /// <param name="series">資料來源</param>
        /// <param name="data_stream">資料串流編號(從 1 開始編號)</param>
        public void AddSeries(object series, int data_stream)
        {
            if (__cAxisX == null && series is IInstrument)
            {
                __cInstrument = series as Instrument;
                __cInstrument.BindResetEvent(onReset);

                __cAxisX = new AxisX(__cInstrument);
                __cAxisX.AxisRectangle = __cChartRect;
                __cAxisX.FontMetrics   = __cPainter.GetFontMetrics("0", __cProperty.AxisFont);
            }

            Layer        cLayer   = null;
            ChartSetting cSetting = __cProperty.ChartSettings[data_stream - 1];
            int          iCount   = __cLayers.Count;

            if (cSetting.LayerIndex < iCount)
            {
                cLayer = __cLayers[cSetting.LayerIndex];
            }
            else
            {
                cLayer            = CreateLayer();
                cLayer.LayerIndex = iCount;

                __cLayers.Add(cLayer);
            }

            __bNewSeries = true;
            this.Resize();

            AbstractPlot cPlot = __cPainter.GetPlot(this, series, cSetting);

            if (cPlot != null)
            {
                cPlot.DataStream = data_stream;
                cPlot.AdjustAxisScaleFromX(__cAxisX);
                cLayer.AddPlot(cPlot);
            }
        }
Пример #2
0
        internal void AddPlot(AbstractPlot plot, AxisY axisY = null)
        {
            if (axisY == null)
            {
                if (__cPlots.Count == 0 || plot.ChartSetting.Axis.IsCreateInstance)
                {
                    Rectangle cAxisRect = this.LayerRectangle;
                    cAxisRect.Width = 0;                      //將寬度設定為0(讓 AxisY 自動計算寬度)

                    plot.CreateAxisY(__cProperty, cAxisRect);
                }
                else
                {
                    plot.AxisY = __cPlots[0].AxisY;
                }
            }
            else
            {
                plot.AxisY = axisY;
            }

            EChartType cChartType = plot.ChartSetting.ChartType;

            switch (cChartType)
            {
            case EChartType.TextObject:
            case EChartType.TradeObject:
                plot.PlotIndex = -1;
                break;

            default:
                plot.PlotIndex = __iMaxPlotCount++;
                break;
            }
            __cPlots.Add(plot);
        }