コード例 #1
0
ファイル: StockChart.cs プロジェクト: tmpkus/openvss
        private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged)
        {
            Chart      chart      = dataPoint.Chart as Chart;
            DataSeries dataSeries = dataPoint.Parent;
            PlotGroup  plotGroup  = dataSeries.PlotGroup;
            Faces      dsFaces    = dataSeries.Faces;
            Faces      dpFaces    = dataPoint.Faces;

            Double dataPointWidth;

            if (dsFaces != null)
            {
                ColumnChart.UpdateParentVisualCanvasSize(chart, dsFaces.Visual as Canvas);
            }

            if (dpFaces != null && dpFaces.Visual != null)
            {
                dataPointWidth = dpFaces.Visual.Width;
            }
            else if (dsFaces == null)
            {
                return;
            }
            else
            {
                dataPointWidth = CandleStick.CalculateDataPointWidth(dsFaces.Visual.Width, dsFaces.Visual.Height, chart);
            }

            if (property == VcProperties.Enabled)
            {
                CreateOrUpdateAStockDataPoint(dataPoint, dsFaces.Visual as Canvas, dsFaces.LabelCanvas, dsFaces.Visual.Width, dsFaces.Visual.Height, dataPointWidth);
                return;
            }

            if (dpFaces == null)
            {
                return;
            }

            Canvas dataPointVisual = dpFaces.Visual as Canvas;            // DataPoint visual canvas
            Line   highLowLine     = dpFaces.VisualComponents[0] as Line; // HighLowline
            Line   closeLine       = dpFaces.VisualComponents[1] as Line; // Closeline
            Line   openLine        = dpFaces.VisualComponents[2] as Line; // Openline

            switch (property)
            {
            case VcProperties.BorderThickness:
            case VcProperties.BorderStyle:
                ApplyBorderProperties(dataPoint, highLowLine, openLine, closeLine, dataPointWidth);
                break;

            case VcProperties.Color:
                ApplyOrUpdateColorForAStockDp(dataPoint, highLowLine, openLine, closeLine);
                break;

            case VcProperties.Cursor:
                dataPoint.SetCursor2DataPointVisualFaces();
                break;

            case VcProperties.Href:
                dataPoint.SetHref2DataPointVisualFaces();
                break;

            case VcProperties.HrefTarget:
                dataPoint.SetHref2DataPointVisualFaces();
                break;

            case VcProperties.LabelBackground:
            case VcProperties.LabelEnabled:
            case VcProperties.LabelFontColor:
            case VcProperties.LabelFontFamily:
            case VcProperties.LabelFontStyle:
            case VcProperties.LabelFontSize:
            case VcProperties.LabelFontWeight:
            case VcProperties.LabelStyle:
            case VcProperties.LabelText:
                CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                break;

            case VcProperties.LegendText:
                chart.InvokeRender();
                break;

            case VcProperties.LightingEnabled:
                ApplyOrUpdateColorForAStockDp(dataPoint, highLowLine, openLine, closeLine);
                break;

            //case VcProperties.MarkerBorderColor:
            //case VcProperties.MarkerBorderThickness:
            //case VcProperties.MarkerColor:
            //case VcProperties.MarkerEnabled:
            //case VcProperties.MarkerScale:
            //case VcProperties.MarkerSize:
            //case VcProperties.MarkerType:
            case VcProperties.ShadowEnabled:
                ApplyOrUpdateShadow(dataPoint, dataPointVisual, highLowLine, openLine, closeLine, dataPointWidth);
                break;

            case VcProperties.Opacity:
                dpFaces.Visual.Opacity = dataSeries.Opacity * dataPoint.Opacity;
                break;

            case VcProperties.ShowInLegend:
                chart.InvokeRender();
                break;

            case VcProperties.ToolTipText:
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                break;

            case VcProperties.XValueFormatString:
            case VcProperties.YValueFormatString:
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                break;

            case VcProperties.XValueType:
                chart.InvokeRender();
                break;

            case VcProperties.Enabled:
                CreateOrUpdateAStockDataPoint(dataPoint, dsFaces.Visual as Canvas, dsFaces.LabelCanvas, dsFaces.Visual.Width, dsFaces.Visual.Height, dataPointWidth);
                break;

            case VcProperties.XValue:
            case VcProperties.YValues:
                if (isAxisChanged)
                {
                    UpdateDataSeries(dataSeries, property, newValue, isAxisChanged);
                }
                else
                {
                    dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                    UpdateYValueAndXValuePosition(dataPoint, dsFaces.Visual.Width, dsFaces.Visual.Height, dpFaces.Visual.Width);

                    if ((Boolean)dataPoint.LabelEnabled)
                    {
                        CandleStick.CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                    }
                }

                if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected)
                {
                    dataPoint.Select(true);
                }

                break;
            }
        }
コード例 #2
0
ファイル: StockChart.cs プロジェクト: tmpkus/openvss
        /// <summary>
        /// Get visual object for point chart
        /// </summary>
        /// <param name="width">Width of the charat</param>
        /// <param name="height">Height of the charat</param>
        /// <param name="plotDetails">plotDetails</param>
        /// <param name="seriesList">List of DataSeries</param>
        /// <param name="chart">Chart</param>
        /// <param name="plankDepth">Plank depth</param>
        /// <param name="animationEnabled">Whether animation is enabled</param>
        /// <returns>Point chart canvas</returns>
        internal static Canvas GetVisualObjectForStockChart(Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, List <DataSeries> seriesList, Chart chart, Double plankDepth, bool animationEnabled)
        {
            if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0)
            {
                return(null);
            }

            Canvas visual, labelCanvas, stockChartCanvas;

            RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out stockChartCanvas, width, height);

            Double depth3d      = plankDepth / (plotDetails.Layer3DCount == 0 ? 1 : plotDetails.Layer3DCount) * (chart.View3D ? 1 : 0);
            Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[seriesList[0]] + 1 - (plotDetails.Layer3DCount == 0 ? 0 : 1));

            visual.SetValue(Canvas.TopProperty, visualOffset);
            visual.SetValue(Canvas.LeftProperty, -visualOffset);

            Double     animationBeginTime = 0;
            DataSeries _tempDataSeries    = null;

            // Calculate width of a DataPoint
            Double dataPointWidth = CandleStick.CalculateDataPointWidth(width, height, chart);

            foreach (DataSeries series in seriesList)
            {
                if (series.Enabled == false)
                {
                    continue;
                }

                Faces dsFaces = new Faces()
                {
                    Visual = stockChartCanvas, LabelCanvas = labelCanvas
                };
                series.Faces = dsFaces;

                PlotGroup plotGroup = series.PlotGroup;
                _tempDataSeries = series;

                foreach (DataPoint dataPoint in series.InternalDataPoints)
                {
                    CreateOrUpdateAStockDataPoint(dataPoint, stockChartCanvas, labelCanvas, width, height, dataPointWidth);
                }
            }

            // Apply animation to series
            if (animationEnabled)
            {
                if (_tempDataSeries.Storyboard == null)
                {
                    _tempDataSeries.Storyboard = new Storyboard();
                }

                _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(stockChartCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1);
                animationBeginTime        += 0.5;
            }

            // Label animation
            if (animationEnabled && _tempDataSeries != null)
            {
                _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1);
            }

            stockChartCanvas.Tag = null;

            // ColumnChart.CreateOrUpdatePlank(chart, seriesList[0].PlotGroup.AxisY, stockChartCanvas, depth3d, Orientation.Horizontal);

            // Remove old visual and add new visual in to the existing panel
            if (preExistingPanel != null)
            {
                visual.Children.RemoveAt(1);
                visual.Children.Add(stockChartCanvas);
            }
            else
            {
                labelCanvas.SetValue(Canvas.ZIndexProperty, 1);
                visual.Children.Add(labelCanvas);
                visual.Children.Add(stockChartCanvas);
            }

            RectangleGeometry clipRectangle = new RectangleGeometry();

            clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH, width + chart.ChartArea.PLANK_OFFSET, height + chart.ChartArea.PLANK_DEPTH);
            visual.Clip        = clipRectangle;

            return(visual);
        }