コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataPoint"></param>
        /// <param name="property"></param>
        /// <param name="newValue"></param>
        /// <param name="isAxisChanged"></param>
        private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged)
        {
            Chart       chart            = dataPoint.Chart as Chart;
            PlotDetails plotDetails      = chart.PlotDetails;
            Marker      marker           = dataPoint.Marker;
            DataSeries  dataSeries       = dataPoint.Parent;
            Canvas      bubleChartCanvas = dataSeries.Faces.Visual as Canvas;

            Double plotHeight = chart.ChartArea.ChartVisualCanvas.Height;
            Double plotWidth = chart.ChartArea.ChartVisualCanvas.Width;
            Double minimumZVal, maximumZVal;

            ColumnChart.UpdateParentVisualCanvasSize(chart, bubleChartCanvas);

            if (property == VcProperties.Enabled)
            {
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal);
                CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight);
                return;
            }

            if (dataPoint.Faces == null)
            {
                return;
            }

            Grid bubbleVisual = dataPoint.Faces.Visual as Grid;

            switch (property)
            {
            case VcProperties.Bevel:
                break;

            case VcProperties.Cursor:
                break;

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

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

            case VcProperties.LabelBackground:
                if (marker != null)
                {
                    marker.TextBackground = dataPoint.LabelBackground;
                }
                break;

            case VcProperties.LabelEnabled:
                CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal);
                CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight);

                //if (marker != null)
                //    marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled;

                break;

            case VcProperties.LabelFontColor:
                if (marker != null)
                {
                    marker.FontColor = dataPoint.LabelFontColor;
                }

                break;

            case VcProperties.LabelFontFamily:
                if (marker != null)
                {
                    marker.FontFamily = dataPoint.LabelFontFamily;
                }
                break;

            case VcProperties.LabelFontStyle:
                if (marker != null)
                {
                    marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
                }
                break;

            //case VcProperties.LabelFontSize:
            //    if (marker != null)
            //        marker.FontSize = (Double)dataPoint.LabelFontSize;
            //    break;

            case VcProperties.LabelFontWeight:
                if (marker != null)
                {
                    marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                }
                break;

            case VcProperties.LabelAngle:
                if (marker != null)
                {
                    marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                }
                break;

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

            case VcProperties.Color:
            case VcProperties.LightingEnabled:
                if (marker != null)
                {
                    marker.MarkerShape.Fill = (chart.View3D ? Graphics.Get3DBrushLighting(dataPoint.Color, (Boolean)dataPoint.LightingEnabled) : ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPoint.Color, "Linear", null) : dataPoint.Color));
                }
                break;

            case VcProperties.MarkerBorderColor:
                if (marker != null)
                {
                    marker.BorderColor = dataPoint.MarkerBorderColor;
                }
                break;

            case VcProperties.MarkerBorderThickness:
                if (marker != null)
                {
                    marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left;
                }
                break;

            case VcProperties.XValueFormatString:
            case VcProperties.YValueFormatString:
            case VcProperties.LabelFontSize:
            case VcProperties.LabelStyle:
            case VcProperties.LabelText:
            case VcProperties.MarkerScale:
            case VcProperties.MarkerSize:
            case VcProperties.MarkerType:
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal);
                CreateOrUpdateAPointDataPoint(bubleChartCanvas, dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight);
                break;

            case VcProperties.ShadowEnabled:
                if (marker != null)
                {
                    marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled;
                    marker.ApplyRemoveShadow();
                }
                break;

            case VcProperties.Opacity:
                if (marker != null)
                {
                    marker.Visual.Opacity = dataPoint.Opacity * dataSeries.Opacity;
                }
                break;

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

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

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

            case VcProperties.XValue:
            case VcProperties.YValue:

                if (isAxisChanged)
                {
                    UpdateDataSeries(dataSeries, property, newValue, false);
                }
                else
                if (marker != null)
                {
                    dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

                    if ((Boolean)dataPoint.LabelEnabled)
                    {
                        marker.Text = dataPoint.TextParser(dataPoint.LabelText);
                    }

                    UpdateBubblePositionAccording2XandYValue(dataPoint, plotWidth, plotHeight, chart.AnimatedUpdate, marker.MarkerShape.Width, marker.MarkerShape.Width);
                }

                break;

            case VcProperties.ZValue:

                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

                //if ((Boolean)dataPoint.LabelEnabled)
                //    marker.Text = dataPoint.TextParser(dataPoint.LabelText);

                CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal);

                foreach (DataPoint dp in dataSeries.InternalDataPoints)
                {
                    if (Double.IsNaN(dp.InternalYValue) || (dp.Enabled == false))
                    {
                        continue;
                    }

                    ApplyZValue(dp, minimumZVal, maximumZVal, plotWidth, plotHeight);
                }

                break;
            }


            if (bubleChartCanvas.Parent != null)
            {
                RectangleGeometry clipRectangle = new RectangleGeometry();
                clipRectangle.Rect = new Rect(0, -(dataPoint.Chart as Chart).ChartArea.PLANK_DEPTH, plotWidth + (dataPoint.Chart as Chart).ChartArea.PLANK_OFFSET, plotHeight + (dataPoint.Chart as Chart).ChartArea.PLANK_DEPTH);
                (bubleChartCanvas.Parent as Canvas).Clip = clipRectangle;
            }
        }
コード例 #2
0
ファイル: PointChart.cs プロジェクト: tmpkus/openvss
        //internal static void Update(Chart chart, RenderAs currentRenderAs, List<DataSeries> selectedDataSeries4Rendering, VcProperties property, object newValue)
        //{
        //    Boolean is3D = chart.View3D;
        //    ChartArea chartArea = chart.ChartArea;
        //    Canvas ChartVisualCanvas = chart.ChartArea.ChartVisualCanvas;

        //    // Double width = chart.ChartArea.ChartVisualCanvas.Width;
        //    // Double height = chart.ChartArea.ChartVisualCanvas.Height;

        //    Panel preExistingPanel = null;
        //    Dictionary<RenderAs, Panel> RenderedCanvasList = chart.ChartArea.RenderedCanvasList;

        //    if (chartArea.RenderedCanvasList.ContainsKey(currentRenderAs))
        //    {
        //        preExistingPanel = RenderedCanvasList[currentRenderAs];
        //    }

        //    Panel renderedChart = chartArea.RenderSeriesFromList(preExistingPanel, selectedDataSeries4Rendering);

        //    if (preExistingPanel == null)
        //    {
        //        chartArea.RenderedCanvasList.Add(currentRenderAs, renderedChart);
        //        ChartVisualCanvas.Children.Add(renderedChart);
        //    }
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="dataPoint"></param>
        /// <param name="property"></param>
        /// <param name="newValue"></param>
        /// <param name="isAxisChanged"></param>
        private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged)
        {
            Chart       chart       = dataPoint.Chart as Chart;
            PlotDetails plotDetails = chart.PlotDetails;
            Marker      marker      = dataPoint.Marker;
            DataSeries  dataSeries  = dataPoint.Parent;

            Canvas pointChartCanvas = dataSeries.Faces.Visual as Canvas;

            Double plotHeight = chart.ChartArea.ChartVisualCanvas.Height;
            Double plotWidth  = chart.ChartArea.ChartVisualCanvas.Width;

            ColumnChart.UpdateParentVisualCanvasSize(chart, pointChartCanvas);

            if (property == VcProperties.Enabled)
            {
                CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight);
                return;
            }

            if (dataPoint.Faces == null)
            {
                return;
            }

            Grid bubbleVisual = dataPoint.Faces.Visual as Grid;

            switch (property)
            {
            case VcProperties.Bevel:
                break;

            case VcProperties.Cursor:
                break;

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

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

            case VcProperties.LabelBackground:
                if (marker != null)
                {
                    marker.TextBackground = dataPoint.LabelBackground;
                }
                break;

            case VcProperties.LabelEnabled:
                CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight);
                //if (marker != null)
                //    marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled;
                break;

            case VcProperties.LabelFontColor:
                if (marker != null)
                {
                    marker.FontColor = dataPoint.LabelFontColor;
                }

                break;

            case VcProperties.LabelFontFamily:
                if (marker != null)
                {
                    marker.FontFamily = dataPoint.LabelFontFamily;
                }
                break;

            case VcProperties.LabelFontStyle:
                if (marker != null)
                {
                    marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
                }
                break;

            //case VcProperties.LabelFontSize:
            //    if (marker != null)
            //        marker.FontSize = (Double)dataPoint.LabelFontSize;
            //    break;

            case VcProperties.LabelFontWeight:
                if (marker != null)
                {
                    marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                }
                break;

            case VcProperties.LabelAngle:
                if (marker != null)
                {
                    marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                }
                break;

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

            case VcProperties.Color:
            case VcProperties.LightingEnabled:
                if (marker != null)
                {
                    marker.MarkerShape.Fill = (chart.View3D ? Graphics.Get3DBrushLighting(dataPoint.Color, (Boolean)dataPoint.LightingEnabled) : ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPoint.Color, "Linear", null) : dataPoint.Color));
                }
                break;

            case VcProperties.MarkerBorderColor:
                if (marker != null)
                {
                    marker.BorderColor = dataPoint.MarkerBorderColor;
                }
                break;

            case VcProperties.MarkerBorderThickness:
                if (marker != null)
                {
                    marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left;
                }
                break;

            case VcProperties.MarkerColor:
                if (marker != null)
                {
                    marker.MarkerFillColor = dataPoint.MarkerColor;
                }
                break;

            case VcProperties.LabelFontSize:
            case VcProperties.LabelStyle:
            case VcProperties.LabelText:
            case VcProperties.MarkerScale:
            case VcProperties.MarkerSize:
            case VcProperties.MarkerType:
                CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight);
                break;

            case VcProperties.ShadowEnabled:
                if (marker != null)
                {
                    marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled;
                    marker.ApplyRemoveShadow();
                }

                break;

            case VcProperties.Opacity:
                if (marker != null)
                {
                    marker.Visual.Opacity = dataPoint.Opacity * dataSeries.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);
                CreateOrUpdateAPointDataPoint(pointChartCanvas, dataPoint, plotWidth, plotHeight);
                break;

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

            case VcProperties.XValue:
            case VcProperties.YValue:
                if (isAxisChanged)
                {
                    UpdateDataSeries(dataSeries, property, newValue, false);
                }
                else
                if (marker != null)
                {
                    dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

                    if ((Boolean)dataPoint.LabelEnabled)
                    {
                        marker.Text = dataPoint.TextParser(dataPoint.LabelText);
                    }

                    BubbleChart.UpdateBubblePositionAccording2XandYValue(dataPoint, plotWidth, plotHeight, chart.AnimatedUpdate, marker.MarkerShape.Width, marker.MarkerShape.Width);
                }

                break;
            }

            if (pointChartCanvas.Parent != null)
            {
                Double tickLengthOfAxisX = (from tick in chart.AxesX[0].Ticks
                                            where (Boolean)chart.AxesX[0].Enabled && (Boolean)tick.Enabled
                                            select tick.TickLength).Sum();

                if (tickLengthOfAxisX == 0)
                {
                    tickLengthOfAxisX = 5;
                }

                Double tickLengthOfPrimaryAxisY = (from axis in chart.AxesY
                                                   where axis.AxisType == AxisTypes.Primary
                                                   from tick in axis.Ticks
                                                   where (Boolean)axis.Enabled && (Boolean)tick.Enabled
                                                   select tick.TickLength).Sum();

                if (tickLengthOfPrimaryAxisY == 0)
                {
                    tickLengthOfPrimaryAxisY = 8;
                }

                Double tickLengthOfSecondaryAxisY = (from axis in chart.AxesY
                                                     where axis.AxisType == AxisTypes.Secondary
                                                     from tick in axis.Ticks
                                                     where (Boolean)axis.Enabled && (Boolean)tick.Enabled
                                                     select tick.TickLength).Sum();

                if (tickLengthOfSecondaryAxisY == 0)
                {
                    tickLengthOfSecondaryAxisY = 8;
                }

                Double plotGroupCount = (from c in chart.PlotDetails.PlotGroups
                                         where c.AxisY.AxisType == AxisTypes.Secondary
                                         select c).Count();

                RectangleGeometry clipRectangle = new RectangleGeometry();
                clipRectangle.Rect = new Rect(-tickLengthOfPrimaryAxisY, -chart.ChartArea.PLANK_DEPTH - 4, plotWidth + tickLengthOfSecondaryAxisY + (plotGroupCount > 0 ? tickLengthOfPrimaryAxisY : 8) + chart.ChartArea.PLANK_OFFSET, plotHeight + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + tickLengthOfAxisX + 4);
                (pointChartCanvas.Parent as Canvas).Clip = clipRectangle;
            }
        }