Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="chartType"></param>
        /// <param name="isPositive"></param>
        /// <param name="columnCanvas"></param>
        /// <param name="labelCanvas"></param>
        /// <param name="dataPoint"></param>
        /// <param name="top"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="finalHeight"></param>
        /// <param name="prevSum"></param>
        /// <param name="absoluteSum">Absolute sum of DataPoints if applicable</param>
        /// <param name="depth3d"></param>
        /// <param name="animationEnabled"></param>
        /// <param name="animationBeginTime"></param>
        private static void CreateStackedBarVisual(RenderAs chartType, Boolean isPositive, Canvas columnCanvas, Canvas labelCanvas,
            DataPoint dataPoint, Double top, ref Double left, ref Double right, Double finalHeight,
            ref Double prevSum, Double absoluteSum, Double depth3d, Boolean animationEnabled,
            Double animationBeginTime, Boolean isTopOFStack, Int32 PositiveOrNegativeZIndex, List<DataPoint> listOfDataPointsInXValue)
        {   
            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;
            Chart chart = dataPoint.Chart as Chart;

            Double percentYValue = 0;

            if (chartType == RenderAs.StackedBar100)
            {
                if (absoluteSum != 0)
                {
                    if (plotGroup.AxisY.Logarithmic)
                    {
                        percentYValue = Math.Log((dataPoint.InternalYValue / absoluteSum * 100), plotGroup.AxisY.LogarithmBase);
                    }
                    else
                        percentYValue = (dataPoint.InternalYValue / absoluteSum * 100);
                }
            }
            else
                percentYValue = dataPoint.InternalYValue;


            if (isPositive)
            {
                if(plotGroup.AxisY.Logarithmic)
                    right = ColumnChart.CalculatePositionOfDataPointForLogAxis(dataPoint, columnCanvas.Width, plotGroup, listOfDataPointsInXValue, absoluteSum);
                else
                    right = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum);
            }
            else
                left = Graphics.ValueToPixelPosition(0, columnCanvas.Width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, percentYValue + prevSum);

            Double barWidth = Math.Abs(right - left);

            prevSum += percentYValue;
            // barParams.Size = new Size(barWidth, finalHeight);

            Faces bar;
            Panel barVisual = null;

            if ((dataPoint.Chart as Chart).View3D)
            {
                bar = ColumnChart.Get3DColumn(dataPoint, barWidth, finalHeight, depth3d, dataPoint.Color, null, null, null, (Boolean)dataPoint.LightingEnabled,
                    (BorderStyles)dataPoint.BorderStyle, dataPoint.BorderColor, dataPoint.BorderThickness.Left);
               
                barVisual = bar.Visual as Panel;
                barVisual.SetValue(Canvas.ZIndexProperty, GetStackedBarZIndex(chart.ChartArea.PlotAreaCanvas.Height, left, top, columnCanvas.Width, columnCanvas.Height, (dataPoint.InternalYValue > 0), PositiveOrNegativeZIndex));

                dataPoint.Faces = bar;
                if (!VisifireControl.IsMediaEffectsEnabled)
                    ColumnChart.ApplyOrRemoveShadow4XBAP(dataPoint, true, false);
            }
            else
            {
                bar = ColumnChart.Get2DColumn(dataPoint, barWidth, finalHeight, true, isTopOFStack);
                barVisual = bar.Visual as Panel;
                dataPoint.Faces = bar;
            }

            if (VisifireControl.IsMediaEffectsEnabled)
                ApplyOrRemoveShadow(chart, dataPoint);

            dataPoint.Faces.LabelCanvas = labelCanvas;

            barVisual.SetValue(Canvas.LeftProperty, left);
            barVisual.SetValue(Canvas.TopProperty, top);

            columnCanvas.Children.Add(barVisual);

            dataPoint.IsTopOfStack = isTopOFStack;

            CreateOrUpdateMarker4HorizontalChart(dataPoint.Chart as Chart, labelCanvas, dataPoint, left, top, isPositive, depth3d);

            //labelCanvas.Children.Add(CreateMarker(chart, barParams, dataPoint, left, top));

            // Apply animation
            if (animationEnabled)
            {
                if (dataPoint.Parent.Storyboard == null)
                    dataPoint.Parent.Storyboard = new Storyboard();

                currentDataSeries = dataPoint.Parent;

                // Apply animation to the data points dataSeriesIndex.e to the rectangles that form the columns
                dataPoint.Parent.Storyboard = ApplyStackedBarChartAnimation(barVisual, dataPoint.Parent.Storyboard, animationBeginTime, 0.5);
            }

            if (isPositive)
                left = right;
            else
                right = left;

            if (isPositive)
                dataPoint._visualPosition = new Point(right, top + finalHeight / 2);
            else
                dataPoint._visualPosition = new Point(left, top + finalHeight / 2);

            dataPoint.Faces.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            
            if(!chart.IndicatorEnabled)
                dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.Visual);
            dataPoint.AttachHref(chart, dataPoint.Faces.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            
            dataPoint.SetCursor2DataPointVisualFaces();
        }
        private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue)
        {
            if (property != VcProperties.Enabled)
            {
                if (dataPoint.Parent.Enabled == false || (Boolean)dataPoint.Enabled == false)
                {
                    return;
                }
            }

            Chart chart = dataPoint.Chart as Chart;

            if (chart == null)
                return;

            Marker marker = dataPoint.Marker;
            DataSeries dataSeries = dataPoint.Parent;
            PlotGroup plotGroup = dataSeries.PlotGroup;
            Double height = chart.ChartArea.ChartVisualCanvas.Height;
            Double width = chart.ChartArea.ChartVisualCanvas.Width;
            Double xPosition, yPosition;
            Canvas line2dLabelCanvas = null;

            xPosition = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);
            yPosition = Graphics.ValueToPixelPosition(height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);

            if (dataSeries.Faces != null)
            {
                line2dLabelCanvas = dataSeries.Faces.LabelCanvas as Canvas;
                ColumnChart.UpdateParentVisualCanvasSize(chart, line2dLabelCanvas);
            }

            switch (property)
            {
                case VcProperties.Color:
                    if (marker != null && (Boolean)dataPoint.MarkerEnabled)
                        marker.BorderColor = (dataPoint.GetValue(DataPoint.MarkerBorderColorProperty) as Brush == null) ? ((newValue != null) ? newValue as Brush : dataPoint.MarkerBorderColor) : dataPoint.MarkerBorderColor;
                    break;
                case VcProperties.Cursor:
                    dataPoint.SetCursor2DataPointVisualFaces();
                    break;

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

                case VcProperties.LabelBackground:
                    //if (marker != null)
                    //    marker.TextBackground = dataPoint.LabelBackground;
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelEnabled:
                    //if (marker.LabelEnabled == false)
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    //else
                    //    marker.LabelEnabled = (Boolean)dataPoint.LabelEnabled;
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelFontColor:
                    //if (marker != null)
                    //    marker.FontColor = dataPoint.LabelFontColor;
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelFontFamily:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    // marker.FontFamily = dataPoint.LabelFontFamily;
                    break;

                case VcProperties.LabelFontStyle:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    //marker.FontStyle = (FontStyle) dataPoint.LabelFontStyle;
                    break;

                case VcProperties.LabelFontSize:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    // marker.FontSize = (Double) dataPoint.LabelFontSize;
                    break;

                case VcProperties.LabelFontWeight:
                    //if (marker != null)
                    //    marker.FontWeight = (FontWeight) dataPoint.LabelFontWeight;
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelStyle:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelAngle:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;

                case VcProperties.LabelText:
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    //marker.Text = dataPoint.TextParser(dataPoint.LabelText);
                    break;

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

                case VcProperties.LightingEnabled:
                    break;

                case VcProperties.MarkerBorderColor:
                    if (marker == null)
                        LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    else
                    {
                        if ((Boolean)dataPoint.MarkerEnabled)
                            marker.BorderColor = dataPoint.MarkerBorderColor;
                    }

                    break;
                case VcProperties.MarkerBorderThickness:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    // marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left;

                    break;

                case VcProperties.MarkerColor:
                    if (marker != null && (Boolean)dataPoint.MarkerEnabled)
                        marker.MarkerFillColor = dataPoint.MarkerColor;
                    break;

                case VcProperties.MarkerEnabled:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);

                    //if((Boolean)dataPoint.MarkerEnabled)
                    //    ShowDataPointMarker(dataPoint);
                    //else
                    //    HideDataPointMarker(dataPoint);
                    break;

                case VcProperties.MarkerScale:
                case VcProperties.MarkerSize:
                case VcProperties.MarkerType:
                case VcProperties.ShadowEnabled:
                    //Double y = Graphics.ValueToPixelPosition(plotGroup.AxisY.Height, 0, plotGroup.AxisY.InternalAxisMinimum, plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);
                    //LineChart.GetMarkerForDataPoint(true, chart, y, dataPoint, dataPoint.InternalYValue > 0);
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);

                    break;

                case VcProperties.Opacity:
                    if (marker != null)
                        marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataSeries.Opacity;
                    break;
                case VcProperties.ShowInLegend:
                    chart.InvokeRender();
                    break;
                case VcProperties.ToolTipText:
                case VcProperties.XValueFormatString:
                case VcProperties.YValueFormatString:
                    dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                    //CreateMarkerAForLineDataPoint(dataPoint, width, height, ref line2dLabelCanvas, out xPosition, out yPosition);
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, xPosition, yPosition,
                        ref line2dLabelCanvas, true);
                    break;
                case VcProperties.XValueType:
                    chart.InvokeRender();
                    break;

                case VcProperties.Enabled:
                    if ((Boolean)dataPoint.Parent.Enabled)
                        UpdateDataSeries(dataPoint, VcProperties.Enabled, newValue);
                    break;

                case VcProperties.XValue:
                    if (Double.IsNaN(dataPoint._oldYValue) || dataPoint.Faces == null) // Broken point of broken line
                        UpdateDataSeries(dataPoint.Parent, property, newValue);
                    else
                        UpdateXAndYValue(dataPoint, line2dLabelCanvas);
                    break;

                case VcProperties.YValue:
                case VcProperties.YValues:
                    if (Double.IsNaN(dataPoint._oldYValue) || Double.IsNaN(dataPoint.InternalYValue) || dataPoint.Faces == null) // Broken point of broken line
                        UpdateDataSeries(dataPoint.Parent, property, newValue);
                    else
                    {
                        //UpdateXAndYValue(dataPoint, ref line2dLabelCanvas);
                        chart.Dispatcher.BeginInvoke(new Action<DataPoint, Canvas>(UpdateXAndYValue), new object[] { dataPoint, line2dLabelCanvas });


                    }

                    break;
            }
        }
Exemple #3
0
        private static void UpdateDataPoint(DataPoint dataPoint, VcProperties property, object newValue, Boolean isAxisChanged)
        {
            Chart chart = dataPoint.Chart as Chart;

            if (chart == null)
                return;

            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 || (dpFaces == null && (property == VcProperties.XValue || property == VcProperties.YValues)))
            {
                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 = (Double)dataSeries.Opacity * (Double)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.YValue:
                case VcProperties.YValues:
                    if (isAxisChanged || dataPoint.InternalYValues == null)
                        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;
            }
        }
Exemple #4
0
        // Canvas bubleChartCanvas, DataPoint dataPoint, Double minimumZVal, Double maximumZVal, Double plotWidth, Double plotHeight
        private static void CreateOrUpdateAPointDataPoint(Canvas pointChartCanvas, DataPoint dataPoint, Double plotAreaWidth, Double plotAreaHeight)
        {   
            Faces dpFaces = dataPoint.Faces;

            // Remove preexisting dataPoint visual and label visual
            if (dpFaces != null && dpFaces.Visual != null && pointChartCanvas == dpFaces.Visual.Parent)
            {
                pointChartCanvas.Children.Remove(dataPoint.Faces.Visual);
                //dpFaces = null;
            }

            dataPoint.Faces = null;
            dpFaces = new Faces();

            if (Double.IsNaN(dataPoint.InternalYValue) || (dataPoint.Enabled == false))
                return;
            
            Chart chart = dataPoint.Chart as Chart;
            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;

            Double xPosition = Graphics.ValueToPixelPosition(0, plotAreaWidth, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);
            Double yPosition = Graphics.ValueToPixelPosition(plotAreaHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);

            Brush markerColor = dataPoint.Color;
            //markerColor = (chart.View3D ? Graphics.GetLightingEnabledBrush3D(markerColor) :
            //    ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(markerColor, "Linear", null) : markerColor));
            
            markerColor = (chart.View3D ? Graphics.Get3DBrushLighting(dataPoint.Color, (Boolean)dataPoint.LightingEnabled) :
                ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(markerColor, "Linear", null) : markerColor));

            Size markerSize = new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize);
            Boolean markerBevel = false;
            String labelText = (Boolean)dataPoint.LabelEnabled ? dataPoint.TextParser(dataPoint.LabelText) : "";
            Marker marker = new Marker((MarkerTypes)dataPoint.MarkerType, (Double)dataPoint.MarkerScale, markerSize, markerBevel, markerColor, labelText);

            marker.Tag = new ElementData() { Element = dataPoint };

            marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled;

            if (!VisifireControl.IsMediaEffectsEnabled)
                marker.PixelLavelShadow = false;
            else
                marker.PixelLavelShadow = true;

            marker.MarkerSize = new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize);

            if (marker.MarkerType != MarkerTypes.Cross)
            {
                if (dataPoint.BorderColor != null)
                    marker.BorderColor = dataPoint.BorderColor;
            }
            else
                marker.BorderColor = markerColor;
            marker.BorderThickness = ((Thickness)dataPoint.MarkerBorderThickness).Left;

            if (!String.IsNullOrEmpty(labelText))
            {
                marker.FontColor = Chart.CalculateDataPointLabelFontColor(chart, dataPoint, dataPoint.LabelFontColor, LabelStyles.OutSide);
                marker.FontSize = (Double)dataPoint.LabelFontSize;
                marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                marker.FontFamily = dataPoint.LabelFontFamily;
                marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
                marker.TextBackground = dataPoint.LabelBackground;

                marker.TextAlignmentX = AlignmentX.Center;
                marker.TextAlignmentY = AlignmentY.Center;

                if (!Double.IsNaN(dataPoint.LabelAngle) && dataPoint.LabelAngle != 0)
                {
                    marker.LabelAngle = dataPoint.LabelAngle;
                    marker.TextOrientation = Orientation.Vertical;

                    marker.TextAlignmentX = AlignmentX.Center;
                    marker.TextAlignmentY = AlignmentY.Center;

                    marker.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
                }

                marker.CreateVisual();

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    if ((yPosition - marker.TextBlockSize.Height / 2) < 0)
                        marker.TextAlignmentY = AlignmentY.Bottom;
                    else if ((yPosition + marker.TextBlockSize.Height / 2) > plotAreaHeight)
                        marker.TextAlignmentY = AlignmentY.Top;

                    if ((xPosition - marker.TextBlockSize.Width / 2) < 0)
                        marker.TextAlignmentX = AlignmentX.Right;
                    else if ((xPosition + marker.TextBlockSize.Width / 2) > plotAreaWidth)
                        marker.TextAlignmentX = AlignmentX.Left;
                }
            }

            //marker.LabelEnabled =(Boolean) dataPoint.LabelEnabled;
            //marker.TextBackground = dataPoint.LabelBackground;
            //marker.FontColor = Chart.CalculateDataPointLabelFontColor(chart, dataPoint, dataPoint.LabelFontColor, LabelStyles.OutSide);
            //marker.FontSize = (Double)dataPoint.LabelFontSize;
            //marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
            //marker.FontFamily = dataPoint.LabelFontFamily;
            //marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;

            //marker.TextAlignmentX = AlignmentX.Center;
            //marker.TextAlignmentY = AlignmentY.Center;

            marker.CreateVisual();

            marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;

            marker.AddToParent(pointChartCanvas, xPosition, yPosition, new Point(0.5, 0.5));

            dataPoint._visualPosition = new Point(xPosition, yPosition);

            dpFaces.VisualComponents.Add(marker.Visual);
            dpFaces.Visual = marker.Visual;

            dpFaces.BorderElements.Add(marker.MarkerShape);

            dataPoint.Marker = marker;
            dataPoint.Faces = dpFaces;

            dataPoint.Faces.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            if(!chart.IndicatorEnabled)
                dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            dataPoint.SetCursor2DataPointVisualFaces();

            if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected)
                dataPoint.Select(true);
        }
Exemple #5
0
        /// <summary>
        /// Creates a new label for a DataPoint
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <returns>Grid</returns>
        private static Canvas CreateLabel(DataPoint dataPoint)
        {
            TextBlock textBlock = new TextBlock()
            {
                FontFamily = dataPoint.LabelFontFamily,
                FontSize = (Double)dataPoint.LabelFontSize,
                FontStyle = (FontStyle)dataPoint.LabelFontStyle,
                FontWeight = (FontWeight)dataPoint.LabelFontWeight,
                Foreground = Chart.CalculateDataPointLabelFontColor((dataPoint.Chart as Chart), dataPoint, dataPoint.LabelFontColor, (LabelStyles)dataPoint.LabelStyle),
                Text = dataPoint.TextParser(dataPoint.LabelText),
                Tag = new ElementData() { Element = dataPoint }
            };

            Size textBlockSize = Graphics.CalculateVisualSize(textBlock);
            if (textBlockSize.Width == 0 && textBlockSize.Width == 0)
            {
                textBlockSize.Width = textBlock.ActualWidth;
                textBlockSize.Height = textBlock.ActualHeight;
            }

            Canvas visual = new Canvas() { Height = textBlockSize.Height, Width = textBlockSize.Width, Background = dataPoint.LabelBackground, Tag = new ElementData() { Element = dataPoint } };

            visual.Opacity = dataPoint.InternalOpacity * dataPoint.Parent.InternalOpacity;

            visual.Children.Add(textBlock);

            dataPoint.LabelVisual = visual;

            return visual;
        }
Exemple #6
0
        /// <summary>
        /// Returns marker for DataPoint
        /// </summary>
        /// <param name="chart">Chart</param>
        /// <param name="position">Marker position</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="isPositive">Whether YValue is positive or negative</param>
        /// <returns>Marker</returns>
        internal static Marker GetMarkerForDataPoint(Boolean reCreate, Chart chart, Double plotWidth, Double plotHeight, Double yPosition, DataPoint dataPoint, Boolean isPositive)
        {
            String labelText;

            if (dataPoint.Parent.RenderAs == RenderAs.Spline || dataPoint.Parent.RenderAs == RenderAs.Line || dataPoint.Parent.RenderAs == RenderAs.StepLine)
                labelText = "";
            else
                labelText = (Boolean)dataPoint.LabelEnabled ? dataPoint.TextParser(dataPoint.LabelText) : "";

            Boolean markerBevel = false;

            if (reCreate)
            {
                //Marker marker = dataPoint.Marker;

                //if(marker != null && marker.Visual != null)
                //{   
                //    Panel parent = marker.Visual.Parent as Panel;

                //    if (parent != null)
                //        parent.Children.Remove(marker.Visual);

                //    marker.MarkerType = (MarkerTypes)dataPoint.MarkerType;
                //    marker.ScaleFactor = (Double)dataPoint.MarkerScale;
                //    marker.MarkerSize = new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize);
                //    marker.Bevel = false;
                //    marker.MarkerFillColor = dataPoint.MarkerColor;
                //    marker.Text = labelText;

                //}
                //else
                {
                    Marker marker = dataPoint.Marker;

                    if (marker != null && marker.Visual != null)
                    {
                        Panel parent = marker.Visual.Parent as Panel;

                        if (parent != null)
                            parent.Children.Remove(marker.Visual);
                    }

                    dataPoint.Marker = new Marker((MarkerTypes)dataPoint.MarkerType,
                        (Double)dataPoint.MarkerScale,
                        new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize),
                        markerBevel,
                        dataPoint.MarkerColor,
                        labelText);
                }
            }
            else
            {   
                Marker marker = dataPoint.Marker;

                marker.MarkerType = (MarkerTypes)dataPoint.MarkerType;
                marker.ScaleFactor = (Double)dataPoint.MarkerScale;
                marker.MarkerSize = new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize);
                marker.Bevel = false;
                marker.MarkerFillColor = dataPoint.MarkerColor;
                marker.Text = labelText;
                marker.TextAlignmentX = AlignmentX.Center;
                marker.TextAlignmentY = AlignmentY.Center;
            }

            ApplyMarkerProperties(dataPoint);

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(labelText))
            {
                ApplyLabelProperties(dataPoint);

                if (!Double.IsNaN(dataPoint.LabelAngle) && dataPoint.LabelAngle != 0)
                {
                    dataPoint.Marker.LabelAngle = dataPoint.LabelAngle;
                    dataPoint.Marker.TextOrientation = Orientation.Vertical;

                    if (isPositive)
                    {
                        dataPoint.Marker.TextAlignmentX = AlignmentX.Center;
                        dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                    }
                    else
                    {
                        dataPoint.Marker.TextAlignmentX = AlignmentX.Center;
                        dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                    }

                    dataPoint.Marker.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
                }

                dataPoint.Marker.CreateVisual();

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    dataPoint.Marker.TextAlignmentX = AlignmentX.Center;

                    if (isPositive)
                    {
                        if (dataPoint.LabelStyle == LabelStyles.OutSide && !dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                        {
                            //if (position < dataPoint.Marker.MarkerActualSize.Height || dataPoint.LabelStyle == LabelStyles.Inside)                            
                            if (yPosition - dataPoint.Marker.MarkerActualSize.Height - dataPoint.Marker.MarkerSize.Height / 2 < 0 || dataPoint.LabelStyle == LabelStyles.Inside)
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                            else
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                        }
                        else if (dataPoint.LabelStyle == LabelStyles.OutSide)
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                        else
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                    }
                    else
                    {
                        if (dataPoint.LabelStyle == LabelStyles.OutSide && !dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                        {
                            if (yPosition + dataPoint.Marker.MarkerActualSize.Height + dataPoint.Marker.MarkerSize.Height / 2 > chart.PlotArea.BorderElement.Height || dataPoint.LabelStyle == LabelStyles.Inside)
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                            else
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                        }
                        else if (dataPoint.LabelStyle == LabelStyles.OutSide)
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                        else
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                    }
                }
            }

            dataPoint.Marker.Control = chart;

            dataPoint.Marker.Tag = new ElementData() { Element = dataPoint };

            dataPoint.Marker.CreateVisual();

            dataPoint.Marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;

            ApplyDefaultInteractivityForMarker(dataPoint);

            //dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            ObservableObject.AttachEvents2Visual(dataPoint, dataPoint, dataPoint.Marker.Visual);
            //dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            ObservableObject.AttachEvents2Visual(dataPoint.Parent, dataPoint, dataPoint.Marker.Visual);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            
            if(!chart.IndicatorEnabled)
                dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Marker.Visual);
            
            dataPoint.AttachHref(chart, dataPoint.Marker.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            dataPoint.SetCursor2DataPointVisualFaces();
            return dataPoint.Marker;
        }
Exemple #7
0
        /// <summary>
        /// Create labels for DataPoint
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <returns>Border</returns>
        private static Border CreateLabelForDataPoint(DataPoint dataPoint, Boolean isStreamLine, Int32 sliceIndex)
        {
            Title title = new Title()
            {
                IsNotificationEnable = false,
                Chart = dataPoint.Chart,
                Text = dataPoint.TextParser(dataPoint.LabelText),
                InternalFontSize = (Double)dataPoint.LabelFontSize,
                InternalFontColor = (isStreamLine && sliceIndex == 0) ? Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, null, LabelStyles.OutSide) : Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (LabelStyles)dataPoint.LabelStyle),
                InternalFontFamily = dataPoint.LabelFontFamily,
                InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                InternalBackground = dataPoint.LabelBackground
            };

            // If its a StreamLine funnel then default size of the Title should be a bit bigger 
            if (isStreamLine && sliceIndex == 0 && dataPoint.GetValue(DataPoint.LabelFontSizeProperty) == null && dataPoint.Parent.GetValue(DataPoint.LabelFontSizeProperty) == null)
            {
                title.InternalFontSize = 11.5;
            }

            title.CreateVisualObject(new ElementData() { Element = dataPoint });

            if (!(Boolean)dataPoint.LabelEnabled)
                title.Visual.Visibility = Visibility.Collapsed;

            return title.Visual;
        }
Exemple #8
0
        private static void CreateColumnDataPointVisual( Canvas parentCanvas, Canvas labelCanvas, PlotDetails plotDetails, DataPoint dataPoint, Boolean isPositive, Double widthOfAcolumn, Double depth3D, Boolean animationEnabled)
        {   
            if (widthOfAcolumn < 0)
                return;
            DataSeries currentDataSeries = dataPoint.Parent;

            Chart chart = dataPoint.Chart as Chart;

            dataPoint.Parent.Faces = new Faces { Visual = parentCanvas, LabelCanvas = labelCanvas };
            
            Double left, bottom, top, columnHeight;
            Size columnVisualSize;

            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;

            Double limitingYValue = 0;

            if (plotGroup.AxisY.InternalAxisMinimum > 0)
                limitingYValue = (Double)plotGroup.AxisY.InternalAxisMinimum;
            if (plotGroup.AxisY.InternalAxisMaximum < 0)
                limitingYValue = (Double)plotGroup.AxisY.InternalAxisMaximum;

            List<DataSeries> indexSeriesList = plotDetails.GetSeriesFromDataPoint(dataPoint);
            Int32 drawingIndex = indexSeriesList.IndexOf(dataPoint.Parent);

            // if (dataPoint.InternalYValue > (Double)plotGroup.AxisY.InternalAxisMaximum)
            //     System.Diagnostics.Debug.WriteLine("Max Value greater then axis max");

            left = Graphics.ValueToPixelPosition(0, parentCanvas.Width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);
            left = left + ((Double)drawingIndex - (Double)indexSeriesList.Count() / (Double)2) * widthOfAcolumn;

//          Double midPosition = Graphics.ValueToPixelPosition(0, parentCanvas.Width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);

            Double zeroBaseLinePos = Graphics.ValueToPixelPosition(parentCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, 0);

            if (isPositive)
            {   
                bottom = Graphics.ValueToPixelPosition(parentCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue);
                top = Graphics.ValueToPixelPosition(parentCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, Double.IsNaN(dataPoint.InternalYValue) ? 0 : dataPoint.InternalYValue);
                
                if (plotGroup.AxisY.AxisMinimum != null && dataPoint.InternalYValue < limitingYValue && chart.View3D)
                {
                    bottom = top = zeroBaseLinePos;
                }
            }
            else
            {   
                bottom = Graphics.ValueToPixelPosition(parentCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, Double.IsNaN(dataPoint.InternalYValue) ? 0 : dataPoint.InternalYValue);
                top = Graphics.ValueToPixelPosition(parentCanvas.Height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue);

                if (plotGroup.AxisY.AxisMinimum != null && limitingYValue>0 && dataPoint.InternalYValue < limitingYValue && chart.View3D)
                {
                    top = bottom = bottom + 100;
                }
            }

            columnHeight = Math.Abs(top - bottom);

            if(columnHeight < dataPoint.Parent.MinPointHeight)
            {
                if (dataPoint.InternalYValue == 0)
                {   
                    if (plotGroup.AxisY.InternalAxisMaximum <= 0)
                        bottom += (dataPoint.Parent.MinPointHeight - columnHeight);
                    else
                        top -= (dataPoint.Parent.MinPointHeight - columnHeight);
                }
                else if (isPositive)
                    top -= (dataPoint.Parent.MinPointHeight - columnHeight);
                else
                    bottom += (dataPoint.Parent.MinPointHeight - columnHeight);
                    
                columnHeight = dataPoint.Parent.MinPointHeight;
            }

            columnVisualSize = new Size(widthOfAcolumn, columnHeight);

            Faces columnFaces = null;
            Panel columnVisual = null;

            if (chart.View3D)
            {
                columnFaces = Get3DColumn(dataPoint, widthOfAcolumn, columnHeight, depth3D, dataPoint.Color, null, null, null, (Boolean)dataPoint.LightingEnabled,
                    (BorderStyles)dataPoint.BorderStyle, dataPoint.BorderColor, dataPoint.BorderThickness.Left);
                columnVisual = columnFaces.Visual as Panel;
                columnVisual.SetValue(Canvas.ZIndexProperty, GetColumnZIndex(left, top, (dataPoint.InternalYValue > 0)));
                
                dataPoint.Faces = columnFaces;

                if (!VisifireControl.IsMediaEffectsEnabled)
                    ColumnChart.ApplyOrRemoveShadow4XBAP(dataPoint, false, false);

            }   
            else
            {   
                columnFaces = Get2DColumn(dataPoint, widthOfAcolumn, columnHeight, false, false);
                columnVisual = columnFaces.Visual as Panel;
            }

            dataPoint.Faces = columnFaces;

            if (VisifireControl.IsMediaEffectsEnabled)
                ColumnChart.ApplyOrRemoveShadow(chart, dataPoint);

            columnVisual.SetValue(Canvas.LeftProperty, left);
            columnVisual.SetValue(Canvas.TopProperty, top);

            parentCanvas.Children.Add(columnVisual);

            dataPoint.IsTopOfStack = true;

            CreateOrUpdateMarker4VerticalChart(dataPoint, labelCanvas, columnVisualSize, left, top);

            if(isPositive)
                dataPoint._visualPosition = new Point(left + columnVisualSize.Width / 2, top);
            else
                dataPoint._visualPosition = new Point(left + columnVisualSize.Width / 2, bottom);

            // Apply animation
            if (animationEnabled)
            {
                if (dataPoint.Parent.Storyboard == null)
                    dataPoint.Parent.Storyboard = new Storyboard();

                currentDataSeries = dataPoint.Parent;
                //dataPoint.Parent.Storyboard.Stop();

                // Apply animation to the data points dataSeriesIndex.e to the rectangles that form the columns
                dataPoint.Parent.Storyboard = ApplyColumnChartAnimation(currentDataSeries, columnVisual, dataPoint.Parent.Storyboard, isPositive, 1, new Double[] { 0, 1 }, new Double[] { 0, 1 }, dataPoint.Parent.RenderAs);

            }

            dataPoint.Faces.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            if(!chart.IndicatorEnabled)
                dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.Visual);
            //dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            dataPoint.AttachHref(chart, dataPoint.Faces.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            //dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            dataPoint.SetCursor2DataPointVisualFaces();
            chart._toolTip.Hide();
        }
Exemple #9
0
        /// <summary>
        /// Returns label for DataPoint
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="columnParams"></param>
        /// <param name="dataPoint"></param>
        /// <param name="canvasLeft"></param>
        /// <param name="canvasTop"></param>
        /// <returns></returns>
        private static void CreateLabel(Chart chart, Size columnVisualSize, Boolean isPositive, Boolean isTopOfStack, DataPoint dataPoint, Double canvasLeft, Double canvasTop, ref Canvas labelCanvas)
        {
            if (dataPoint.Faces == null)
                return;          

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(dataPoint.LabelText))
            {
                LabelStyles autoLabelStyle = (LabelStyles)dataPoint.LabelStyle;

                if (isPositive || dataPoint.YValue == 0)
                    isPositive = true;

                // Calculate proper position for Canvas top
                if (isPositive)
                    canvasTop -= 6;
                else
                    canvasTop -= 8;

                Double angle = 0;

                Title tb = new Title()
                {   
                    Text = dataPoint.TextParser(dataPoint.LabelText),
                    InternalFontFamily = dataPoint.LabelFontFamily,
                    InternalFontSize = dataPoint.LabelFontSize.Value,
                    InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                    InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                    InternalBackground = dataPoint.LabelBackground,
                    InternalFontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, autoLabelStyle),
                    Padding = new Thickness(0.1, 0.1, 0.1, 0.1),
                    Tag = new ElementData() { Element = dataPoint }
                };

                tb.CreateVisualObject(new ElementData() { Element = dataPoint });

                Double labelLeft = 0;
                Double labelTop = 0;
                Double outsideGap = 4;
                Double insideGap = 6;

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    Boolean isVertical = false;
                    if (columnVisualSize.Width < tb.TextBlockDesiredSize.Width)
                    {
                        tb.Visual.RenderTransformOrigin = new Point(0, 0.5);
                        tb.Visual.RenderTransform = new RotateTransform()
                        {
                            CenterX = 0,
                            CenterY = 0,
                            Angle = -90
                        };

                        isVertical = true;
                    }
                    else
                        isVertical = false;

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet && !isTopOfStack && dataPoint.Parent.RenderAs != RenderAs.Column)
                    {
                        autoLabelStyle = LabelStyles.Inside;
                    }

                    if (dataPoint.Parent.RenderAs == RenderAs.StackedColumn100 && chart.View3D
                        && isTopOfStack)
                    {
                        if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet && !isVertical && tb.TextBlockDesiredSize.Height >= columnVisualSize.Height)
                            autoLabelStyle = LabelStyles.OutSide;
                    }

                    CalculateAutoPlacement(chart.View3D, dataPoint, columnVisualSize, isPositive, autoLabelStyle, ref labelLeft, ref labelTop, ref angle,
                        canvasLeft, canvasTop, isVertical, insideGap, outsideGap, tb, isTopOfStack);

                    tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                    tb.Visual.SetValue(Canvas.TopProperty, labelTop);

                    tb.Visual.RenderTransformOrigin = new Point(0, 0.5);
                    tb.Visual.RenderTransform = new RotateTransform()
                    {
                        CenterX = 0,
                        CenterY = 0,
                        Angle = angle
                    };
                    
                    Double depth3D = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0);

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                    {
                        if (isPositive)
                        {   
                            if (isVertical)
                            {
                                if (labelTop + outsideGap - tb.TextBlockDesiredSize.Width < -depth3D)
                                    autoLabelStyle = LabelStyles.Inside;
                            }
                            else
                            {
                                if (labelTop < -depth3D)
                                    autoLabelStyle = LabelStyles.Inside;
                            }
                        }
                        else
                        {
                            if (isVertical)
                            {
                                if (labelTop + outsideGap + 2 > chart.PlotArea.BorderElement.Height - depth3D + chart.ChartArea.PLANK_THICKNESS)
                                    autoLabelStyle = LabelStyles.Inside;
                            }
                            else
                            {
                                if (labelTop + tb.TextBlockDesiredSize.Height > chart.PlotArea.BorderElement.Height - depth3D + chart.ChartArea.PLANK_THICKNESS)
                                    autoLabelStyle = LabelStyles.Inside;
                            }
                        }
                    }

                    if (autoLabelStyle != dataPoint.LabelStyle)
                    {
                        CalculateAutoPlacement(chart.View3D, dataPoint, columnVisualSize, isPositive, autoLabelStyle, ref labelLeft, ref labelTop, ref angle,
                        canvasLeft, canvasTop, isVertical, insideGap, outsideGap, tb, isTopOfStack);

                        tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                        tb.Visual.SetValue(Canvas.TopProperty, labelTop);

                        tb.Visual.RenderTransformOrigin = new Point(0, 0.5);
                        tb.Visual.RenderTransform = new RotateTransform()
                        {
                            CenterX = 0,
                            CenterY = 0,
                            Angle = angle
                        };
                    }

                    if (chart.SmartLabelEnabled)
                    {
                        if (dataPoint.Parent.RenderAs == RenderAs.StackedColumn || dataPoint.Parent.RenderAs == RenderAs.StackedColumn100)
                        {
                            if (isVertical)
                            {
                                if (autoLabelStyle == LabelStyles.Inside)
                                {
                                    if (columnVisualSize.Height < tb.Visual.Width)
                                        return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (isPositive)
                    {
                        Point centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2,
                            canvasTop - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale));

                        Double radius = 0;
                        angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2,
                            canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale));
                            radius = 4;
                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 5;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                radius += 5;
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                    else
                    {
                        Point centerOfRotation = new Point();

                        Double radius = 0;
                        angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2,
                            canvasTop + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale) + 10);

                            radius = 4;

                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(canvasLeft + columnVisualSize.Width / 2,
                            canvasTop - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale));

                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                //radius += 3;  
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                }

                if (autoLabelStyle != dataPoint.LabelStyle)
                {
                    tb.TextElement.Foreground = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (dataPoint.YValue == 0 ? LabelStyles.OutSide : autoLabelStyle));
                }

                dataPoint.LabelVisual = tb.Visual;
                labelCanvas.Children.Add(tb.Visual);

            }
        }
Exemple #10
0
        /// <summary>
        /// Get Marker for DataPoint
        /// </summary>
        /// <param name="chart">Chart</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="position">position of the marker</param>
        /// <param name="isPositive">Whether DataPoint Value is positive or negative</param>
        /// <returns>Marker</returns>
        internal static Marker GetMarkerForDataPoint(Chart chart, Double height, Boolean isTopOfStack, DataPoint dataPoint, Double position, bool isPositive)
        {
            if ((Boolean)dataPoint.MarkerEnabled || (Boolean)dataPoint.LabelEnabled)
            {
                Size markerSize = (Boolean)dataPoint.MarkerEnabled ? new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize) : new Size(0, 0);
                String labelText = (Boolean)dataPoint.LabelEnabled ? dataPoint.TextParser(dataPoint.LabelText) : "";

                dataPoint.Marker = CreateNewMarker(chart, dataPoint, markerSize, labelText);

                if (true && !String.IsNullOrEmpty(labelText))
                {
                    if (!Double.IsNaN(dataPoint.LabelAngle) && dataPoint.LabelAngle != 0)
                    {
                        dataPoint.Marker.LabelAngle = dataPoint.LabelAngle;
                        dataPoint.Marker.TextOrientation = Orientation.Vertical;

                        if (isPositive)
                        {
                            dataPoint.Marker.TextAlignmentX = AlignmentX.Center;
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                        }
                        else
                        {
                            dataPoint.Marker.TextAlignmentX = AlignmentX.Center;
                            dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                        }

                        dataPoint.Marker.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
                    }

                    dataPoint.Marker.CreateVisual();

                    if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                    {
                        dataPoint.Marker.TextAlignmentX = AlignmentX.Center;

                        if (isPositive)
                        {
                            if (dataPoint.LabelStyle == LabelStyles.OutSide && !dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                            {
                                if (!isTopOfStack)
                                {
                                    if (position + dataPoint.Marker.TextBlockSize.Height > height)
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                                    else
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                                }
                                else
                                {
                                    //if (position < dataPoint.Marker.MarkerActualSize.Height || dataPoint.LabelStyle == LabelStyles.Inside)
                                    if (position - dataPoint.Marker.MarkerActualSize.Height - dataPoint.Marker.MarkerSize.Height / 2 < 0 || dataPoint.LabelStyle == LabelStyles.Inside)
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                                    else
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                                }
                            }
                            else if (dataPoint.LabelStyle == LabelStyles.OutSide)
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                            else
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                        }
                        else
                        {
                            if (dataPoint.LabelStyle == LabelStyles.OutSide && !dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                            {
                                if (!isTopOfStack)
                                    dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                                else
                                {
                                    if (position + dataPoint.Marker.MarkerActualSize.Height + dataPoint.Marker.MarkerSize.Height / 2 > chart.PlotArea.BorderElement.Height || dataPoint.LabelStyle == LabelStyles.Inside)
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                                    else
                                        dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                                }
                            }
                            else if (dataPoint.LabelStyle == LabelStyles.OutSide)
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Bottom;
                            else
                                dataPoint.Marker.TextAlignmentY = AlignmentY.Top;
                        }

                    }
                }

                dataPoint.Marker.CreateVisual();

                return dataPoint.Marker;
            }

            return null;
        }
Exemple #11
0
        internal static void CreateOrUpdateAStockDataPoint(DataPoint dataPoint, Canvas stockChartCanvas, Canvas labelCanvas, Double canvasWidth, Double canvasHeight, Double dataPointWidth)
        {
            Faces dpFaces = dataPoint.Faces;

            // Remove preexisting dataPoint visual and label visual
            if (dpFaces != null && dpFaces.Visual != null && stockChartCanvas == dpFaces.Visual.Parent)
            {   
                stockChartCanvas.Children.Remove(dataPoint.Faces.Visual);
            }

            // Remove preexisting label visual
            if (dataPoint.LabelVisual != null && dataPoint.LabelVisual.Parent == labelCanvas)
            {
                labelCanvas.Children.Remove(dataPoint.LabelVisual);
            }

            dataPoint.Faces = null;

            if (dataPoint.YValues == null || dataPoint.Enabled == false)
                return;

            // Initialize DataPoint faces
            dataPoint.Faces = new Faces();
            
            // Creating ElementData for Tag
            ElementData tagElement = new ElementData() { Element = dataPoint };

            // Create DataPoint Visual
            Canvas dataPointVisual = new Canvas();          // Create DataPoint Visual
            Line highLow = new Line(){ Tag = tagElement };  // Create High and Low Line
            Line closeLine = new Line(){ Tag = tagElement };    // Create Close Line
            Line openLine = new Line() { Tag = tagElement };    // Create Close Line

            dataPoint.Faces.Visual = dataPointVisual;

            // Add VisualComponents
            dataPoint.Faces.VisualComponents.Add(highLow);
            dataPoint.Faces.VisualComponents.Add(openLine);
            dataPoint.Faces.VisualComponents.Add(closeLine);

            // Add Border elements
            dataPoint.Faces.BorderElements.Add(highLow);
            dataPoint.Faces.BorderElements.Add(openLine);
            dataPoint.Faces.BorderElements.Add(closeLine);

            dataPoint.Faces.Visual = dataPointVisual;
            stockChartCanvas.Children.Add(dataPointVisual);
            
            UpdateYValueAndXValuePosition(dataPoint, canvasWidth, canvasHeight, dataPointWidth);
            ApplyBorderProperties(dataPoint, highLow, openLine, closeLine, dataPointWidth);
            ApplyOrUpdateColorForAStockDp(dataPoint, highLow, openLine, closeLine);
                        
            // Add VisualComponents to visual
            dataPointVisual.Children.Add(highLow);
            dataPointVisual.Children.Add(openLine);
            dataPointVisual.Children.Add(closeLine);

            // Attach tooltip, events, href etc
            dataPointVisual.Opacity = dataPoint.Parent.Opacity * dataPoint.Opacity;
            Chart chart = dataPoint.Chart as Chart;
            dataPoint.SetCursor2DataPointVisualFaces();
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
        }
Exemple #12
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;
            PlotGroup plotGroup = dataSeries.PlotGroup;
            Canvas areaVisual = dataSeries.Faces.Visual as Canvas;
            Canvas labelCanvas = ((areaVisual as FrameworkElement).Parent as Panel).Children[0] as Canvas;
            Double height = chart.ChartArea.ChartVisualCanvas.Height;
            Double width = chart.ChartArea.ChartVisualCanvas.Width;
            Double xPosition, yPosition;
            Faces faces = dataPoint.Faces;

            switch (property)
            {    
                 case VcProperties.Bevel:
                     UpdateDataSeries(dataSeries, property, newValue);
                     break;

                case VcProperties.Color:
                case VcProperties.LightingEnabled:
                     if (property != VcProperties.LightingEnabled && marker != null && (Boolean)dataPoint.MarkerEnabled)
                         marker.BorderColor = (dataPoint.GetValue(DataPoint.MarkerBorderColorProperty) as Brush == null) ? ((newValue != null) ? newValue as Brush : dataPoint.MarkerBorderColor) : dataPoint.MarkerBorderColor;

                    if (faces != null)
                    {
                        if(dataPoint.Faces.BevelLine != null)
                            dataPoint.Faces.BevelLine.Stroke = Graphics.GetBevelTopBrush(dataPoint.Parent.Color);

                        Brush sideBrush = (Boolean)dataSeries.LightingEnabled ? Graphics.GetRightFaceBrush(dataSeries.Color) : dataSeries.Color;
                        Brush topBrush = (Boolean)dataSeries.LightingEnabled ? Graphics.GetTopFaceBrush(dataSeries.Color) : dataSeries.Color;

                        if (dataPoint.Faces.Area3DLeftFace != null)
                            (dataPoint.Faces.Area3DLeftFace.LeftFace as Path).Fill = sideBrush;

                        if (dataPoint.Faces.Area3DRightTopFace != null)
                            (dataPoint.Faces.Area3DRightTopFace.TopFace as Path).Fill = topBrush;

                        if (dataPoint.Faces.Area3DLeftTopFace != null)
                            (dataPoint.Faces.Area3DLeftTopFace.TopFace as Path).Fill = topBrush;

                        if (dataPoint.Faces.Area3DRightFace != null)
                            (dataPoint.Faces.Area3DRightFace.RightFace as Path).Fill = sideBrush;
                    }

                    break;

                case VcProperties.Opacity:

                    Double opacity = dataPoint.Opacity * dataSeries.Opacity;
                    if (marker != null)
                        marker.Visual.Opacity = opacity;

                    if (faces != null)
                    {   
                        if (dataPoint.Faces.BevelLine != null)
                            dataPoint.Faces.BevelLine.Opacity = opacity;

                        if (dataPoint.Faces.Area3DLeftFace != null)
                            (dataPoint.Faces.Area3DLeftFace.LeftFace as Path).Opacity = opacity;

                        if (dataPoint.Faces.Area3DRightTopFace != null)
                            (dataPoint.Faces.Area3DRightTopFace.TopFace as Path).Opacity = opacity;

                        if (dataPoint.Faces.Area3DLeftTopFace != null)
                            (dataPoint.Faces.Area3DLeftTopFace.TopFace as Path).Opacity = opacity;

                        if (dataPoint.Faces.Area3DRightFace != null)
                            (dataPoint.Faces.Area3DRightFace.RightFace as Path).Opacity = opacity;
                    }

                    break;
                case VcProperties.BorderColor:
                case VcProperties.BorderStyle:
                case VcProperties.BorderThickness:
                    if (faces != null)
                    {
                        if (dataPoint.Faces.Area3DLeftFace != null)
                            ApplyBorderProperties(dataPoint.Faces.Area3DLeftFace.LeftFace as Path, dataSeries);

                        if (dataPoint.Faces.Area3DRightTopFace != null)
                            ApplyBorderProperties(dataPoint.Faces.Area3DRightTopFace.TopFace as Path, dataSeries);

                        if (dataPoint.Faces.Area3DLeftTopFace != null)
                            ApplyBorderProperties(dataPoint.Faces.Area3DLeftTopFace.TopFace as Path, dataSeries);

                        if (dataPoint.Faces.Area3DRightFace != null)
                            ApplyBorderProperties(dataPoint.Faces.Area3DRightFace.RightFace as Path, dataSeries);
                    }

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

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

                case VcProperties.LabelBackground:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    marker.TextBackground = dataPoint.LabelBackground;
                    break;

                case VcProperties.LabelEnabled:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    break;

                case VcProperties.LabelFontColor:
                    marker.FontColor = dataPoint.LabelFontColor;
                    break;

                case VcProperties.LabelFontFamily:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    // marker.FontFamily = dataPoint.LabelFontFamily;
                    break;

                case VcProperties.LabelFontStyle:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);

                    //marker.FontStyle = (FontStyle) dataPoint.LabelFontStyle;
                    break;

                case VcProperties.LabelFontSize:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);

                    // marker.FontSize = (Double) dataPoint.LabelFontSize;
                    break;

                case VcProperties.LabelFontWeight:
                    marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                    break;

                case VcProperties.LabelStyle:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    break;

                case VcProperties.LabelText:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    //marker.Text = dataPoint.TextParser(dataPoint.LabelText);
                    break;

                case VcProperties.LabelAngle:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    //marker.Text = dataPoint.TextParser(dataPoint.LabelText);
                    break;

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

                case VcProperties.MarkerBorderColor:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);

                    //marker.BorderColor = dataPoint.MarkerBorderColor;
                    break;
                case VcProperties.MarkerBorderThickness:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    //marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left;
                    break;

                case VcProperties.MarkerColor:
                    if(marker != null && (Boolean) dataPoint.MarkerEnabled)
                        marker.MarkerFillColor = dataPoint.MarkerColor;
                    break;

                case VcProperties.MarkerEnabled:
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);

                    // if((Boolean)dataPoint.MarkerEnabled)
                    //    ShowDataPointMarker(dataPoint);
                    // else
                    //    HideDataPointMarker(dataPoint);
                    break;

                case VcProperties.MarkerScale:
                case VcProperties.MarkerSize:
                case VcProperties.MarkerType:
                case VcProperties.ShadowEnabled:
                    // Double y = Graphics.ValueToPixelPosition(plotGroup.AxisY.Height, 0, plotGroup.AxisY.InternalAxisMinimum, plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);
                    // LineChart.GetMarkerForDataPoint(true, chart, y, dataPoint, dataPoint.InternalYValue > 0);
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    break;

              

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

                case VcProperties.ToolTipText:
                case VcProperties.XValueFormatString:
                case VcProperties.YValueFormatString:
                    dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                    LineChart.CreateMarkerAForLineDataPoint(dataPoint, width, height, ref labelCanvas, out xPosition, out yPosition);
                    break;

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

                case VcProperties.Enabled:
                    UpdateDataSeries(dataSeries, property, newValue);
                    break;

                case VcProperties.XValue:
                    UpdateDataSeries(dataSeries, property, newValue);
                    break;

                case VcProperties.YValue:

                    if (isAxisChanged || dataPoint._oldYValue > 0 && dataPoint.InternalYValue < 0 || dataPoint._oldYValue < 0 && dataPoint.InternalYValue > 0)
                        UpdateDataSeries(dataSeries, property, newValue);
                    else
                    {
                        dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
                        UpdateVisualForYValue4AreaChart(chart, dataPoint, isAxisChanged);
                        //chart.Dispatcher.BeginInvoke(new Action<Chart, DataPoint, Boolean>(UpdateVisualForYValue4AreaChart), new object[] { chart, dataPoint, isAxisChanged});

                    }

                    chart._toolTip.Hide();
                    // chart.Dispatcher.BeginInvoke(new Action<DataPoint>(UpdateXAndYValue), new object[]{dataPoint});

                    break;
            }
        }
Exemple #13
0
        private static void UpdateXAndYValue(DataPoint dataPoint, Canvas line2dLabelCanvas)
        {
            Boolean isAnimationEnabled = (dataPoint.Chart as Chart).AnimatedUpdate;

            if (!(Boolean)dataPoint.Enabled)
                return;

            Chart chart = dataPoint.Chart as Chart;
            DataSeries dataSeries = dataPoint.Parent;
            dataSeries._movingMarker.Visibility = Visibility.Collapsed;

            Axis axisX = dataSeries.PlotGroup.AxisX;
            Axis axisY = dataSeries.PlotGroup.AxisY;

            Marker dataPointMarker = dataPoint.Marker;
            Marker legendMarker = dataPoint.LegendMarker;


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

            Double x = Graphics.ValueToPixelPosition(0, width, axisX.InternalAxisMinimum, axisX.InternalAxisMaximum, dataPoint.InternalXValue);
            Double y = Graphics.ValueToPixelPosition(height, 0, axisY.InternalAxisMinimum, axisY.InternalAxisMaximum, dataPoint.InternalYValue);

            dataPoint._visualPosition = new Point(x, y);
            Point newMarkerPosition = new Point();
            Point newLabelPosition = new Point();

            if(dataPointMarker != null)
                newMarkerPosition = dataPointMarker.CalculateActualPosition(x, y, new Point(0.5, 0.5));

            if ((Boolean)dataPoint.LabelEnabled)
            {   
                if (isAnimationEnabled && dataPoint.LabelVisual != null)
                {
                    dataPoint._oldLabelPosition = new Point((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty), (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty));
                    newLabelPosition = CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, x, y, ref line2dLabelCanvas, false);

                    dataPoint.LabelVisual.SetValue(Canvas.TopProperty, dataPoint._oldLabelPosition.Y);
                    dataPoint.LabelVisual.SetValue(Canvas.LeftProperty, dataPoint._oldLabelPosition.X);
                }
                else
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, x, y, ref line2dLabelCanvas, true);
            }

            if (!isAnimationEnabled)
            {   
                if (dataPointMarker != null && dataPointMarker.Visual != null)
                {   
                    dataPointMarker.Visual.SetValue(Canvas.TopProperty, newMarkerPosition.Y);
                    dataPointMarker.Visual.SetValue(Canvas.LeftProperty, newMarkerPosition.X);
                }
            }

            DependencyObject target, shadowTarget = null;    // Target object
            Point oldPoint = new Point();                    // Old Position

            // Collect reference of line geometry object
            LineSegment lineSeg = dataPoint.Faces.Parts[0] as LineSegment;
            PathFigure pathFigure = dataPoint.Faces.Parts[1] as PathFigure;

            LineSegment shadowLineSeg;
            PathFigure shadowPathFigure;

            // For line shadow
            if(dataPoint.Parent.ShadowEnabled)
            {   
                shadowLineSeg = dataPoint.ShadowFaces.Parts[0] as LineSegment;
                shadowPathFigure = dataPoint.ShadowFaces.Parts[1] as PathFigure;

                if (shadowLineSeg == null)
                {
                    shadowTarget = shadowPathFigure;
                    if (!isAnimationEnabled)
                        shadowPathFigure.StartPoint = new Point(x, y);
                }
                else
                {
                    shadowTarget = shadowLineSeg;
                    if (!isAnimationEnabled)
                        shadowLineSeg.Point = new Point(x, y);
                }
            }

            if (lineSeg == null)
            {   
                target = pathFigure;

                if (isAnimationEnabled)
                {
                    if (dataPoint.Storyboard != null)
                        dataPoint.Storyboard.Pause();

                    oldPoint = pathFigure.StartPoint;
                }
                else
                    pathFigure.StartPoint = new Point(x, y);
            }
            else
            {   
                target = lineSeg;
                
                if(isAnimationEnabled)
                { 
                    if (dataPoint.Storyboard != null)
                        dataPoint.Storyboard.Pause();
                    
                    oldPoint = lineSeg.Point;
                }
                else
                    lineSeg.Point = new Point(x, y);
            }

            if (isAnimationEnabled)
            {   
                #region Apply Animation to the DataPoint

                Storyboard storyBorad = new Storyboard();
                PointAnimation pointAnimation = new PointAnimation();

                pointAnimation.From = oldPoint;
                pointAnimation.To = new Point(x, y);
                pointAnimation.SpeedRatio = 2;
                pointAnimation.Duration = new Duration(new TimeSpan(0, 0, 1));

                //target.SetValue(FrameworkElement.NameProperty, "Segment_" + dataPoint.Name);

                Storyboard.SetTarget(pointAnimation, target);
//#if SL
                Storyboard.SetTargetProperty(pointAnimation, (lineSeg != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
//#else
               // Storyboard.SetTargetProperty(pointAnimation, (lineSeg != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));

//#endif
                Storyboard.SetTargetName(pointAnimation, (String)target.GetValue(FrameworkElement.NameProperty));

                storyBorad.Children.Add(pointAnimation);

                if (shadowTarget != null)
                {   
                    pointAnimation = new PointAnimation();

                    pointAnimation.From = oldPoint;
                    pointAnimation.To = new Point(x, y);
                    pointAnimation.SpeedRatio = 2;
                    pointAnimation.Duration = new Duration(new TimeSpan(0, 0, 1));

                    shadowTarget.SetValue(FrameworkElement.NameProperty, "ShadowSegment_" + dataPoint.Name);
                    
                    Storyboard.SetTarget(pointAnimation, shadowTarget);
                    Storyboard.SetTargetProperty(pointAnimation, (lineSeg != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
                    Storyboard.SetTargetName(pointAnimation, (String)shadowTarget.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(pointAnimation);

#if WPF
                    if (lineSeg != null)
                        (shadowTarget as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation);
                    else
                        (shadowTarget as PathFigure).BeginAnimation(PathFigure.StartPointProperty, pointAnimation);
#endif
                }

                #endregion

                #region Attach Animation with Marker

                FrameworkElement marker = dataPoint.Marker.Visual;

                if (marker != null)
                {
                    // Animation for (Canvas.Top) property
                    DoubleAnimation da = new DoubleAnimation()
                    {
                        From = (Double)marker.GetValue(Canvas.LeftProperty),
                        To = newMarkerPosition.X,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, marker);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                    Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                    // Animation for (Canvas.Top) property
                    da = new DoubleAnimation()
                    {
                        From = (Double)marker.GetValue(Canvas.TopProperty),
                        To = newMarkerPosition.Y,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, marker);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                    Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);
                }

                #endregion

                #region Attach Animation with Label

                FrameworkElement label = dataPoint.LabelVisual;

                if (label != null)
                {
                    // Animation for (Canvas.Top) property
                    DoubleAnimation da = new DoubleAnimation()
                    {
                        From = dataPoint._oldLabelPosition.X,
                        To = newLabelPosition.X,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, label);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                    Storyboard.SetTargetName(da, (String)label.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                    // Animation for (Canvas.Top) property
                    da = new DoubleAnimation()
                    {
                        From = dataPoint._oldLabelPosition.Y,
                        To = newLabelPosition.Y,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, label);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                    Storyboard.SetTargetName(da, (String)label.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                }

                #endregion

                dataPoint.Storyboard = storyBorad;
#if WPF
                if (lineSeg != null)
                    (target as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation);
                else
                    (target as PathFigure).BeginAnimation(PathFigure.StartPointProperty, pointAnimation);
#endif
                // Start the animation
                storyBorad.Begin();
            }

            //chart.ChartArea.ChartVisualCanvas.Background = new SolidColorBrush(Colors.Blue);
            dataSeries.Faces.Visual.Width = chart.ChartArea.ChartVisualCanvas.Width;
            dataSeries.Faces.Visual.Height = chart.ChartArea.ChartVisualCanvas.Height;

            dataSeries.Faces.LabelCanvas.Width = chart.ChartArea.ChartVisualCanvas.Width;
            dataSeries.Faces.LabelCanvas.Height = chart.ChartArea.ChartVisualCanvas.Height;

            // Update ToolTip Text
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            
            if(dataSeries._movingMarker != null)
                dataSeries._movingMarker.Visibility = Visibility.Collapsed;
            
            chart._toolTip.Hide();

            if (dataSeries.Faces != null)
            {
                RectangleGeometry clipRectangle = new RectangleGeometry();

                Double depth3d = chart.ChartArea.PLANK_DEPTH / (chart.PlotDetails.Layer3DCount == 0 ? 1 : chart.PlotDetails.Layer3DCount) * (chart.View3D ? 1 : 0);

                Double clipLeft = 0;
                Double clipTop = -depth3d - 4;
                Double clipWidth = width + depth3d;
                Double clipHeight = height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10;

                AreaChart.GetClipCoordinates(chart, ref clipLeft, ref clipTop, ref clipWidth, ref clipHeight, dataSeries.PlotGroup.MinimumX, dataSeries.PlotGroup.MaximumX);

                clipRectangle.Rect = new Rect(clipLeft, clipTop, clipWidth, clipHeight);

                if (dataSeries.Faces.LabelCanvas != null && dataSeries.Faces.LabelCanvas.Parent != null)
                    (dataSeries.Faces.LabelCanvas.Parent as Canvas).Clip = clipRectangle;

                clipRectangle = new RectangleGeometry();
                clipRectangle.Rect = new Rect(0, -depth3d - 4, width + depth3d, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + 10);

                if (dataSeries.Faces.Visual != null)
                    (dataSeries.Faces.Visual.Parent as Canvas).Clip = clipRectangle;
            }

        }
Exemple #14
0
        /// <summary>
        /// Create labels for DataPoint
        /// </summary>
        /// <param name="dataPoint">DataPoint</param>
        /// <returns>Border</returns>
        private static Border CreateLabelForDataPoint(DataPoint dataPoint, Int32 sliceIndex)
        {
            Title title = new Title()
            {
                IsNotificationEnable = false,
                Chart = dataPoint.Chart,
                Text = dataPoint.TextParser(dataPoint.LabelText),
                InternalFontSize = (Double)dataPoint.LabelFontSize,
                InternalFontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (LabelStyles)dataPoint.LabelStyle),
                InternalFontFamily = dataPoint.LabelFontFamily,
                InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                InternalBackground = dataPoint.LabelBackground
            };

            title.CreateVisualObject(new ElementData() { Element = dataPoint });

            if (!(Boolean)dataPoint.LabelEnabled)
                title.Visual.Visibility = Visibility.Collapsed;

            return title.Visual;
        }
Exemple #15
0
        /// <summary>
        /// Returns label for DataPoint
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="barParams"></param>
        /// <param name="dataPoint"></param>
        /// <param name="canvasLeft"></param>
        /// <param name="canvasTop"></param>
        /// <param name="canvasRight"></param>
        /// <returns></returns>
        private static void CreateLabel(Chart chart, Size barVisualSize, Boolean isPositive, Boolean isTopOfStack, DataPoint dataPoint,
            Double canvasLeft, Double canvasTop, Double canvasRight, Canvas labelCanvas)
        {
            if (dataPoint.Faces == null)
                return;

            LabelStyles autoLabelStyle = (LabelStyles)dataPoint.LabelStyle;

            if (isPositive || dataPoint.YValue == 0)
                isPositive = true;

            // Calculate proper position for Canvas top
            canvasTop -= 7;

            Double angle = 0;

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(dataPoint.LabelText))
            {
                Title tb = new Title()
                {
                    Text = dataPoint.TextParser(dataPoint.LabelText),
                    InternalFontFamily = dataPoint.LabelFontFamily,
                    InternalFontSize = dataPoint.LabelFontSize.Value,
                    InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                    InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                    InternalBackground = dataPoint.LabelBackground,
                    InternalFontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, autoLabelStyle),
                    Tag = new ElementData() { Element = dataPoint }

                };

                tb.CreateVisualObject(new ElementData() { Element = dataPoint });

                Double labelTop = 0;
                Double labelLeft = 0;

                Double outsideGap = (chart.View3D ? 5 : 3);
                Double insideGap = (chart.View3D ? 4 : 3);

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    Boolean isVertical = false;

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet && !isTopOfStack && dataPoint.Parent.RenderAs != RenderAs.Bar)
                    {
                        autoLabelStyle = LabelStyles.Inside;
                    }

                    CalculateAutoPlacement(chart.View3D, dataPoint, barVisualSize, isPositive, autoLabelStyle, ref labelLeft, ref labelTop, ref angle,
                        canvasLeft, canvasTop, canvasRight, isVertical, insideGap, outsideGap, tb);

                    tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                    tb.Visual.SetValue(Canvas.TopProperty, labelTop);

                    tb.Visual.RenderTransformOrigin = new Point(0, 0.5);
                    tb.Visual.RenderTransform = new RotateTransform()
                    {
                        CenterX = 0,
                        CenterY = 0,
                        Angle = angle
                    };

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                    {
                        if (isPositive)
                        {
                            if (labelLeft + tb.TextBlockDesiredSize.Width > chart.PlotArea.BorderElement.Width)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                        else
                        {
                            if (labelLeft < 0)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                    }

                    if (autoLabelStyle != dataPoint.LabelStyle)
                    {
                        CalculateAutoPlacement(chart.View3D, dataPoint, barVisualSize, isPositive, autoLabelStyle, ref labelLeft, ref labelTop, ref angle,
                        canvasLeft, canvasTop, canvasRight, isVertical, insideGap, outsideGap, tb);

                        tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                        tb.Visual.SetValue(Canvas.TopProperty, labelTop);
                    }

                    if (chart.SmartLabelEnabled)
                    {
                        if (dataPoint.Parent.RenderAs == RenderAs.StackedBar || dataPoint.Parent.RenderAs == RenderAs.StackedBar100)
                        {
                            if (!isVertical)
                            {
                                if (autoLabelStyle == LabelStyles.Inside)
                                {
                                    if (barVisualSize.Width < tb.Visual.Width)
                                        return;
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (isPositive)
                    {
                        Point centerOfRotation = new Point(canvasRight + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale),
                            canvasTop + barVisualSize.Height / 2 + 6);

                        Double radius = 0;
                        angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            if (dataPoint.LabelAngle <= 90 && dataPoint.LabelAngle >= -90)
                            {
                                angle = dataPoint.LabelAngle;
                                radius += 4;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(canvasRight - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale),
                            canvasTop + barVisualSize.Height / 2 + 6);

                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 4;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                    else
                    {
                        Point centerOfRotation = new Point(canvasLeft - (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale),
                            canvasTop + barVisualSize.Height / 2 + 6);

                        Double radius = 0;
                        angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(canvasLeft + (((Double)dataPoint.MarkerSize / 2) * (Double)dataPoint.MarkerScale),
                            canvasTop + barVisualSize.Height / 2 + 6);

                            if (dataPoint.LabelAngle <= 90 && dataPoint.LabelAngle >= -90)
                            {
                                angle = dataPoint.LabelAngle;
                                radius += 3;
                                angleInRadian = (Math.PI / 180) * angle;
                                SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                }

                if (autoLabelStyle != dataPoint.LabelStyle)
                {
                    tb.TextElement.Foreground = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (dataPoint.YValue == 0 ? LabelStyles.OutSide : autoLabelStyle));
                }

                dataPoint.LabelVisual = tb.Visual;
                labelCanvas.Children.Add(tb.Visual);
            }
        }
Exemple #16
0
        /// <summary>
        /// Set column parameters
        /// </summary>
        /// <param name="columnParams">Column parameters</param>
        /// <param name="chart">Chart reference</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="IsPositive">Whether the DataPoint YValue is positive or negative</param>
        internal static void SetColumnParms(ref RectangularChartShapeParams columnParams, ref Chart chart, DataPoint dataPoint, Boolean isPositive)
        {
            columnParams.Bevel = dataPoint.Parent.Bevel;
            columnParams.Lighting = (Boolean)dataPoint.LightingEnabled;
            columnParams.Shadow = (Boolean)dataPoint.ShadowEnabled;
            columnParams.BorderBrush = dataPoint.BorderColor;
            columnParams.BorderThickness = ((Thickness)dataPoint.BorderThickness).Left;
            columnParams.BorderStyle = ExtendedGraphics.GetDashArray((BorderStyles)dataPoint.BorderStyle);
            columnParams.IsPositive = isPositive;
            columnParams.BackgroundBrush = dataPoint.Color;

            columnParams.IsMarkerEnabled = (Boolean)dataPoint.MarkerEnabled;
            columnParams.MarkerType = (MarkerTypes)dataPoint.MarkerType;
            columnParams.MarkerColor = dataPoint.MarkerColor;
            columnParams.MarkerBorderColor = dataPoint.MarkerBorderColor;
            columnParams.MarkerBorderThickness = (Thickness)dataPoint.MarkerBorderThickness;
            columnParams.MarkerScale = (Double)dataPoint.MarkerScale;
            columnParams.MarkerSize = (Double)dataPoint.MarkerSize;

            columnParams.IsLabelEnabled = (Boolean)dataPoint.LabelEnabled;
            columnParams.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
            columnParams.LabelText = dataPoint.TextParser(dataPoint.LabelText);
            columnParams.LabelBackground = dataPoint.LabelBackground;
            columnParams.LabelFontColor = dataPoint.LabelFontColor;
            columnParams.LabelFontSize = (Double)dataPoint.LabelFontSize;
            columnParams.LabelFontFamily = dataPoint.LabelFontFamily;
            columnParams.LabelFontStyle = (FontStyle)dataPoint.LabelFontStyle;
            columnParams.LabelFontWeight = (FontWeight)dataPoint.LabelFontWeight;

            columnParams.TagReference = dataPoint;
        }
Exemple #17
0
        internal static void CreateBarDataPointVisual(DataPoint dataPoint, Canvas labelCanvas, Canvas columnCanvas , Boolean isPositive, Double heightPerBar, Double depth3d, Boolean animationEnabled)
        {
            Double xValue = dataPoint.InternalXValue;
            Double width = columnCanvas.Width, height = columnCanvas.Height;
            Chart chart = dataPoint.Chart as Chart;
            PlotDetails plotDetails = chart.PlotDetails;
            
            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;
            Double limitingYValue = 0;

            if (plotGroup.AxisY.InternalAxisMinimum > 0)
                limitingYValue = (Double)plotGroup.AxisY.InternalAxisMinimum;
            if (plotGroup.AxisY.InternalAxisMaximum < 0)
                limitingYValue = (Double)plotGroup.AxisY.InternalAxisMaximum;

            List<DataSeries> indexSeriesList = plotDetails.GetSeriesFromDataPoint(dataPoint);
            Int32 drawingIndex = indexSeriesList.IndexOf(dataPoint.Parent);

            Double zeroBaseLine = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, 0);

            Double top = Graphics.ValueToPixelPosition(height, 0, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, xValue);
            top = top + ((Double)drawingIndex - (Double)indexSeriesList.Count() / (Double)2) * heightPerBar;

            Double left, right;

            if (isPositive)
            {   
                left = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue);
                right = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, Double.IsNaN(dataPoint.InternalYValue) ? 0 : dataPoint.InternalYValue);

                if (plotGroup.AxisY.AxisMinimum != null && dataPoint.InternalYValue < limitingYValue)
                {
                    //if (right < left)
                    //{
                    //    Double temp = left;
                    //    left = right;
                    //    right = left;
                    //}

                    left = right = zeroBaseLine;
                }
            }
            else
            {   
                left = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, Double.IsNaN(dataPoint.InternalYValue) ? 0 : dataPoint.InternalYValue);
                right = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue);

                if (plotGroup.AxisY.AxisMinimum != null && limitingYValue > 0 && dataPoint.InternalYValue < limitingYValue && chart.View3D)
                {
                    right = left = zeroBaseLine - 100; 
                }
            }
            
            Double columnWidth = Math.Abs(left - right);

            if (columnWidth < dataPoint.Parent.MinPointHeight)
            {
                if (dataPoint.InternalYValue == 0)
                {
                    if (plotGroup.AxisY.InternalAxisMaximum <= 0)
                        left -= (dataPoint.Parent.MinPointHeight - columnWidth);
                    else
                       right += (dataPoint.Parent.MinPointHeight - columnWidth);
                }
                else if (isPositive)
                    right += (dataPoint.Parent.MinPointHeight - columnWidth);
                else
                    left -= (dataPoint.Parent.MinPointHeight - columnWidth);

                columnWidth = dataPoint.Parent.MinPointHeight;
            }

            Double columnHeight = CalculateHeightOfEachColumn(ref top, heightPerBar, height);

            if (columnHeight < 0)
                return;
            
            Faces column;
            Panel columnVisual = null;

            if (chart.View3D)
            {   
                // column = Get3DBar(barParams);
                column = ColumnChart.Get3DColumn(dataPoint, columnWidth, columnHeight, depth3d, dataPoint.Color, 
                    null, null, null, (Boolean)dataPoint.LightingEnabled, (BorderStyles)dataPoint.BorderStyle, 
                    dataPoint.BorderColor, dataPoint.BorderThickness.Left);
              
                columnVisual = column.Visual as Panel;
                columnVisual.SetValue(Canvas.ZIndexProperty, GetBarZIndex(left, top, height, dataPoint.InternalYValue > 0));

                dataPoint.Faces = column;

                if (!VisifireControl.IsMediaEffectsEnabled)
                    ColumnChart.ApplyOrRemoveShadow4XBAP(dataPoint, false, false);

            }
            else
            {   
                // column = Get2DBar(barParams);
                column = ColumnChart.Get2DColumn(dataPoint, columnWidth, columnHeight, false, false);
                columnVisual = column.Visual as Panel;

                dataPoint.Faces = column;
            }

            if (VisifireControl.IsMediaEffectsEnabled)
                ApplyOrRemoveShadow(chart, dataPoint);

            dataPoint.Faces.LabelCanvas = labelCanvas;
            dataPoint.Parent.Faces = new Faces() { Visual = columnCanvas, LabelCanvas = labelCanvas };

            columnVisual.SetValue(Canvas.LeftProperty, left);
            columnVisual.SetValue(Canvas.TopProperty, top);

            columnCanvas.Children.Add(columnVisual);

            dataPoint.IsTopOfStack = true;

            CreateOrUpdateMarker4HorizontalChart(chart, labelCanvas, dataPoint, left, top, isPositive, depth3d);

            if (isPositive)
                dataPoint._visualPosition = new Point(right, top + columnHeight / 2);
            else
                dataPoint._visualPosition = new Point(left, top + columnHeight / 2);

            dataPoint.Faces.LabelCanvas = labelCanvas;

            // Apply animation
            if (animationEnabled)
            {
                if (dataPoint.Parent.Storyboard == null)
                    dataPoint.Parent.Storyboard = new Storyboard();

                currentDataSeries = dataPoint.Parent;

                // Apply animation to the bars 
                dataPoint.Parent.Storyboard = ApplyBarChartAnimation(columnVisual, dataPoint.Parent.Storyboard, isPositive);
            }

            dataPoint.Faces.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            //dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            //dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            if(!chart.IndicatorEnabled)
                dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.Visual);
            dataPoint.AttachHref(chart, dataPoint.Faces.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);

            dataPoint.SetCursor2DataPointVisualFaces();
        }
Exemple #18
0
        internal static void UpdateBubblePositionAccording2XandYValue(DataPoint dataPoint, Double drawingAreaWidth, Double drawingAreaHeight, Boolean animatedUpdate, Double oldSize, Double newSize)
        {
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

            //animatedUpdate = false;
            Marker marker = dataPoint.Marker;
            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;

            Double xPosition = Graphics.ValueToPixelPosition(0, drawingAreaWidth, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);
            Double yPosition = Graphics.ValueToPixelPosition(drawingAreaHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);

            if (animatedUpdate)
            {
                Point newPosition = marker.CalculateActualPosition(xPosition, yPosition, new Point(0.5, 0.5));
                ApplyAnimation4XYZUpdate(dataPoint, newPosition, oldSize, newSize);
                
                //dataPoint.Storyboard.SpeedRatio = 2;
                //dataPoint.Storyboard.Begin();
            }
            else
                marker.SetPosition(xPosition, yPosition, new Point(0.5, 0.5));

            if (dataPoint.Parent.ToolTipElement != null)
                dataPoint.Parent.ToolTipElement.Hide();

            (dataPoint.Chart as Chart).ChartArea.DisableIndicators();

            dataPoint._visualPosition = new Point(xPosition, yPosition);
        }
Exemple #19
0
        /// <summary>
        /// Get marker for DataPoint
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="plotWidth"></param>
        /// <param name="plotHeight"></param>
        /// <param name="yPosition"></param>
        /// <param name="dataPoint"></param>
        /// <param name="isPositionTop"></param>
        /// <returns></returns>
        private static Marker GetMarkerForDataPoint(Chart chart, Double plotWidth, Double plotHeight, Double yPosition, DataPoint dataPoint, Boolean isPositionTop)
        {
            String labelText = (Boolean)dataPoint.LabelEnabled ? dataPoint.TextParser(dataPoint.LabelText) : "";

            Boolean markerBevel = false;

            Marker marker = dataPoint.Marker;

            if (marker != null && marker.Visual != null)
            {
                Panel parent = marker.Visual.Parent as Panel;

                if (parent != null)
                    parent.Children.Remove(marker.Visual);
            }

            dataPoint.Marker = new Marker((MarkerTypes)dataPoint.MarkerType,
                (Double)dataPoint.MarkerScale,
                new Size((Double)dataPoint.MarkerSize, (Double)dataPoint.MarkerSize),
                markerBevel,
                dataPoint.MarkerColor,
                labelText);

            LineChart.ApplyMarkerProperties(dataPoint);

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(labelText))
            {
                LineChart.ApplyLabelProperties(dataPoint);

                if (!Double.IsNaN(dataPoint.LabelAngle) && dataPoint.LabelAngle != 0)
                {
                    dataPoint.Marker.LabelAngle = dataPoint.LabelAngle;
                    dataPoint.Marker.TextOrientation = Orientation.Vertical;

                    SetPositionForDataPointLabel(chart, isPositionTop, dataPoint, yPosition);

                    dataPoint.Marker.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
                }

                dataPoint.Marker.CreateVisual();

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    dataPoint.Marker.TextAlignmentX = AlignmentX.Center;

                    SetPositionForDataPointLabel(chart, isPositionTop, dataPoint, yPosition);
                }
            }

            dataPoint.Marker.Control = chart;

            dataPoint.Marker.Tag = new ElementData() { Element = dataPoint };

            dataPoint.Marker.CreateVisual();

            dataPoint.Marker.Visual.Opacity = (Double)dataPoint.Opacity * (Double)dataPoint.Parent.Opacity;

            LineChart.ApplyDefaultInteractivityForMarker(dataPoint);

            ObservableObject.AttachEvents2Visual(dataPoint, dataPoint, dataPoint.Marker.Visual);
            ObservableObject.AttachEvents2Visual(dataPoint.Parent, dataPoint, dataPoint.Marker.Visual);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Marker.Visual);
            dataPoint.AttachHref(chart, dataPoint.Marker.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            dataPoint.SetCursor2DataPointVisualFaces();
            return dataPoint.Marker;
        }
Exemple #20
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;

            if (chart == null)
                return;

            PlotDetails plotDetails = chart.PlotDetails;
            Marker marker = dataPoint.Marker;
            DataSeries dataSeries = dataPoint.Parent;

            if (dataSeries.Faces == null)
                return;

            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.Faces == null || Double.IsNaN(dataPoint.InternalYValue)) && (property == VcProperties.XValue || property == VcProperties.YValue)))
            {   
                dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

                // Calculate max and min ZValue from all DataSeries
                List<DataSeries> seriesList = (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Bubble && ((Boolean)ds.Enabled == true) select ds).ToList(); 
                CalculateMaxAndMinZValueFromAllSeries(ref seriesList, 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 = (Double)dataPoint.Opacity * (Double)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:
                case VcProperties.YValues:
                case VcProperties.DataPoints:

                    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, (Boolean)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);

                    List<DataSeries> seriesList = (from ds in chart.InternalSeries where ds.RenderAs == RenderAs.Bubble && ((Boolean)ds.Enabled == true) select ds).ToList();
                    CalculateMaxAndMinZValueFromAllSeries(ref seriesList, out minimumZVal, out maximumZVal);
                        
                    // CalculateMaxAndMinZValue(dataPoint.Parent, out minimumZVal, out maximumZVal);
                    foreach (DataSeries ds in seriesList)
                    {
                        foreach (DataPoint dp in ds.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;
            }
        }
Exemple #21
0
        /// <summary>
        /// Creates visual object for a StackedColumn
        /// </summary>
        /// <param name="isPositive">Whether the DataPoint YValue is greater than or equals to 0.</param>
        /// <param name="columnCanvas"></param>
        /// <param name="labelCanvas"></param>
        /// <param name="dataPoint"></param>
        /// <param name="isTopOFStack"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="bottom"></param>
        /// <param name="columnWidth"></param>
        /// <param name="depth3d"></param>
        /// <param name="prevSum"></param>
        /// <param name="positiveOrNegativeIndex"></param>
        /// <param name="animationEnabled"></param>
        private static void CreateStackedColumnVisual(Boolean isPositive, Canvas columnCanvas, Canvas labelCanvas, 
            DataPoint dataPoint, Boolean isTopOFStack, Double left, ref Double top, ref Double bottom, Double columnWidth, 
            Double columnHeight, Double depth3d, ref Int32 positiveOrNegativeIndex, Boolean animationEnabled, 
            Double animationBeginTime)
        {   
            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;
            Chart chart = dataPoint.Chart as Chart;         

            Faces column;
            Panel columnVisual = null;

            dataPoint.Parent.Faces = new Faces { Visual = columnCanvas, LabelCanvas = labelCanvas };
            
            if (chart.View3D)
            {   
                column = ColumnChart.Get3DColumn(dataPoint, columnWidth, columnHeight, depth3d, dataPoint.Color, null, null, null, (Boolean)dataPoint.LightingEnabled,
                (BorderStyles)dataPoint.BorderStyle, dataPoint.BorderColor, dataPoint.BorderThickness.Left);
                columnVisual = column.Visual as Panel;
                columnVisual.SetValue(Canvas.ZIndexProperty, ColumnChart.GetStackedColumnZIndex(left, top, (dataPoint.InternalYValue > 0), positiveOrNegativeIndex));
                dataPoint.Faces = column;
                ColumnChart.ApplyOrRemoveShadow(dataPoint, true, false);
            }
            else
            {   
                column = ColumnChart.Get2DColumn(dataPoint, columnWidth, columnHeight, true, false);
                columnVisual = column.Visual as Panel;
            }

            dataPoint.Faces = column;
            dataPoint.Faces.LabelCanvas = labelCanvas;

            columnVisual.SetValue(Canvas.LeftProperty, left);
            columnVisual.SetValue(Canvas.TopProperty, top);

            columnCanvas.Children.Add(columnVisual);

            dataPoint.IsTopOfStack = isTopOFStack;

            CreateOrUpdateMarker4VerticalChart(dataPoint, labelCanvas, new Size(columnVisual.Width, columnVisual.Height),
                          left, top);
            
            // labelCanvas.Children.Add(GetMarker(chart, columnParams, dataPoint, left, top));

            DataSeries currentDataSeries;

            // Apply animation
            if (animationEnabled)
            {
                currentDataSeries = dataPoint.Parent;

                if (currentDataSeries.Storyboard == null)
                    currentDataSeries.Storyboard = new Storyboard();

                // Apply animation to the data points dataSeriesIndex.e to the rectangles that form the columns
                currentDataSeries.Storyboard = ApplyStackedColumnChartAnimation(currentDataSeries, columnVisual, dataPoint.Parent.Storyboard, animationBeginTime, 0.5);
            }

            if (isPositive)
                bottom = top;
            else
                top = bottom;

            dataPoint.Faces.Visual.Opacity = dataPoint.Opacity * dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            //dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            //dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            
            dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.Visual);
            dataPoint.AttachHref(chart, dataPoint.Faces.Visual, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            
            dataPoint.SetCursor2DataPointVisualFaces();
        }
Exemple #22
0
        /// <summary>
        /// Create or update a CandleStick
        /// </summary>
        /// <param name="dataPoint"></param>
        /// <param name="seriesCanvas"></param>
        /// <param name="labelCanvas"></param>
        /// <param name="canvasWidth"></param>
        /// <param name="canvasHeight"></param>
        /// <param name="dataPointWidth"></param>
        internal static void CreateOrUpdateACandleStick(DataPoint dataPoint, Canvas candleStickCanvas, Canvas labelCanvas, Double canvasWidth, Double canvasHeight, Double dataPointWidth)
        {
            Faces dpFaces = dataPoint.Faces;

            // Remove preexisting dataPoint visual and label visual
            if (dpFaces != null && dpFaces.Visual != null && candleStickCanvas == dpFaces.Visual.Parent)
            {
                candleStickCanvas.Children.Remove(dataPoint.Faces.Visual);
                //dpFaces = null;
            }

            // Remove preexisting label visual
            if(dataPoint.LabelVisual != null && dataPoint.LabelVisual.Parent == labelCanvas)
            {
                labelCanvas.Children.Remove(dataPoint.LabelVisual);
                //dataPoint.LabelVisual = null;
            }

            dataPoint.Faces = null;

            if (dataPoint.YValues == null || dataPoint.Enabled == false)
                return;

            // Creating ElementData for Tag
            ElementData tagElement = new ElementData() { Element = dataPoint };

            // Initialize DataPoint faces
            dataPoint.Faces = new Faces();
            
            // Create DataPoint Visual
            Canvas dataPointVisual = new Canvas();
            dataPoint.Faces.Visual = dataPointVisual;

            // Create High and Low Line
            Line highLowLine = new Line() { Tag = tagElement };
            
            dataPoint.Faces.Parts.Add(highLowLine);
            dataPoint.Faces.VisualComponents.Add(highLowLine);
            dataPointVisual.Children.Add(highLowLine);

            /* Create Open-Close Rectangle
             * Math.Max is used to make sure that the rectangle is visible 
             * even when the difference between high and low is 0 */
            Rectangle openCloseRect = new Rectangle() { Tag = tagElement };
            
            dataPoint.Faces.VisualComponents.Add(openCloseRect);
            dataPoint.Faces.BorderElements.Add(openCloseRect);
            dataPointVisual.Children.Add(openCloseRect);

            UpdateYValueAndXValuePosition(dataPoint, canvasWidth, canvasHeight, dataPointWidth);

            // Add dataPointVisual to seriesCanvas
            candleStickCanvas.Children.Add(dataPointVisual);

            CreateAndPositionLabel(labelCanvas, dataPoint);

            dataPointVisual.Opacity = dataPoint.Parent.Opacity * dataPoint.Opacity;

            Chart chart = dataPoint.Chart as Chart;
            dataPoint.SetCursor2DataPointVisualFaces();
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
        }
Exemple #23
0
        //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;

            if (chart == null)
                return;

            PlotDetails plotDetails = chart.PlotDetails;
            Marker marker = dataPoint.Marker;
            DataSeries dataSeries = dataPoint.Parent;

            if (dataSeries.Faces == null)
                return;

            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 || ((dataPoint.Faces == null || Double.IsNaN(dataPoint.InternalYValue)) && (property == VcProperties.XValue || property == VcProperties.YValue)))
            {
                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 = (Double)dataPoint.Opacity * (Double)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:
                case VcProperties.YValues:
                case VcProperties.DataPoints:
                    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, (Boolean)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 (Double)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 (Double)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 (Double)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;
            }
        }
Exemple #24
0
        /// <summary>
        /// Place label for DataPoint
        /// </summary>
        /// <param name="visual">Visual</param>
        /// <param name="labelCanvas">Canvas for label</param>
        /// <param name="dataPoint">DataPoint</param>
        internal static void CreateAndPositionLabel(Canvas labelCanvas, DataPoint dataPoint)
        {   
            if (dataPoint.LabelVisual != null)
            {
                Panel parent = dataPoint.LabelVisual.Parent as Panel;

                if(parent != null)
                    parent.Children.Remove(dataPoint.LabelVisual);
            }
            
            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(dataPoint.LabelText))
            {   
                Canvas dataPointVisual = dataPoint.Faces.Visual as Canvas;

                Title tb = new Title()
                {   
                    Text = dataPoint.TextParser(dataPoint.LabelText),
                    FontFamily = dataPoint.LabelFontFamily,
                    FontSize = dataPoint.LabelFontSize.Value,
                    FontWeight = (FontWeight)dataPoint.LabelFontWeight,
                    FontStyle = (FontStyle)dataPoint.LabelFontStyle,
                    Background = dataPoint.LabelBackground,
                    FontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, LabelStyles.OutSide)
                };

                tb.CreateVisualObject(new ElementData() { Element = dataPoint });
                tb.Visual.Height = tb.Height;
                tb.Visual.Width = tb.Width;
                dataPoint.LabelVisual = tb.Visual;

                // Double labelTop = (Double)dataPointVisual.GetValue(Canvas.TopProperty) - tb.Height;
                // Double labelLeft = (Double)dataPointVisual.GetValue(Canvas.LeftProperty) + (dataPointVisual.Width - tb.Width) / 2;

                // if (labelTop < 0) labelTop = (Double)dataPointVisual.GetValue(Canvas.TopProperty);
                // if (labelLeft < 0) labelLeft = 1;
                // if (labelLeft + tb.ActualWidth > labelCanvas.Width)
                //    labelLeft = labelCanvas.Width - tb.ActualWidth - 2;

                // tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                // tb.Visual.SetValue(Canvas.TopProperty, labelTop);

                SetLabelPosition(dataPoint, labelCanvas.Width, labelCanvas.Height);

                labelCanvas.Children.Add(tb.Visual);
            }
        }
Exemple #25
0
        /// <summary>
        /// Returns label for DataPoint
        /// </summary>
        /// <param name="dataPoint"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="isPositive"></param>
        /// <param name="markerLeft"></param> 
        /// <param name="markerTop"></param> 
        /// <param name="labelCanvas"></param> 
        /// <param name="IsSetPosition">Whether to set the position while creating it (in this function itself) </param>
        /// <returns>New position of the label</returns>
        private static Point CreateLabel4LineDataPoint(DataPoint dataPoint, Double width, Double height, Boolean isPositive,
            Double markerLeft, Double markerTop, ref Canvas labelCanvas, Boolean IsSetPosition)
        {
            Point retVal = new Point();

            if (dataPoint.LabelVisual != null)
            {
                Panel parent = dataPoint.LabelVisual.Parent as Panel;

                if (parent != null)
                    parent.Children.Remove(dataPoint.LabelVisual);
            }

            Chart chart = dataPoint.Chart as Chart;

            if (dataPoint.Faces == null || Double.IsNaN(dataPoint.InternalYValue))
                return retVal;

            if ((Boolean)dataPoint.LabelEnabled && !String.IsNullOrEmpty(dataPoint.LabelText))
            {
                LabelStyles autoLabelStyle = (LabelStyles)dataPoint.LabelStyle;

                Title tb = new Title()
                {
                    Text = dataPoint.TextParser(dataPoint.LabelText),
                    InternalFontFamily = dataPoint.LabelFontFamily,
                    InternalFontSize = dataPoint.LabelFontSize.Value,
                    InternalFontWeight = (FontWeight)dataPoint.LabelFontWeight,
                    InternalFontStyle = (FontStyle)dataPoint.LabelFontStyle,
                    InternalBackground = dataPoint.LabelBackground,
                    InternalFontColor = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, autoLabelStyle),
                    Padding = new Thickness(0.1, 0.1, 0.1, 0.1),
                    Tag = new ElementData() { Element = dataPoint }
                };

                tb.CreateVisualObject(new ElementData() { Element = dataPoint });

                Double labelLeft = 0;
                Double labelTop = 0;
                Double gap = 6;

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    SetLabelPosition4LineDataPoint(dataPoint, width, height, isPositive, markerLeft, markerTop, ref labelLeft, ref labelTop, gap, new Size(tb.TextBlockDesiredSize.Width, tb.TextBlockDesiredSize.Height));

                    retVal.X = labelLeft;
                    retVal.Y = labelTop;

                    if (IsSetPosition)
                    {
                        tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                        tb.Visual.SetValue(Canvas.TopProperty, labelTop);
                    }

                    Double depth3D = chart.ChartArea.PLANK_DEPTH / chart.PlotDetails.Layer3DCount * (chart.View3D ? 1 : 0);

                    if (!dataPoint.IsLabelStyleSet && !dataPoint.Parent.IsLabelStyleSet)
                    {
                        if (isPositive)
                        {
                            if (labelTop < -depth3D)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                        else
                        {
                            if (labelTop + tb.TextBlockDesiredSize.Height > chart.PlotArea.BorderElement.Height - depth3D + chart.ChartArea.PLANK_THICKNESS)
                                autoLabelStyle = LabelStyles.Inside;
                        }
                    }

                    if (autoLabelStyle != dataPoint.LabelStyle)
                    {
                        SetLabelPosition4LineDataPoint(dataPoint, width, height, isPositive, markerLeft, markerTop, ref labelLeft, ref labelTop, gap, new Size(tb.TextBlockDesiredSize.Width, tb.TextBlockDesiredSize.Height));

                        retVal.X = labelLeft;
                        retVal.Y = labelTop;

                        if (IsSetPosition)
                        {
                            tb.Visual.SetValue(Canvas.LeftProperty, labelLeft);
                            tb.Visual.SetValue(Canvas.TopProperty, labelTop);
                        }
                    }
                }
                else
                {
                    if (isPositive)
                    {
                        Point centerOfRotation = new Point(markerLeft,
                            markerTop - tb.TextBlockDesiredSize.Height / 2);
                        Double radius = dataPoint.Marker.MarkerSize.Height / 2 * dataPoint.Marker.ScaleFactor;
                        Double angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop + dataPoint.Marker.MarkerSize.Height / 2);
                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                //radius += 3;
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                    else
                    {
                        Point centerOfRotation = new Point();
                        Double radius = dataPoint.Marker.MarkerSize.Height / 2 * dataPoint.Marker.ScaleFactor;
                        Double angle = 0;
                        Double angleInRadian = 0;

                        if (autoLabelStyle == LabelStyles.OutSide)
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop + dataPoint.Marker.MarkerSize.Height / 2);

                            if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                angle = 180 + dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                        else
                        {
                            centerOfRotation = new Point(markerLeft,
                                markerTop - dataPoint.Marker.MarkerSize.Height / 2);

                            if (dataPoint.LabelAngle > 0 && dataPoint.LabelAngle <= 90)
                            {
                                angle = dataPoint.LabelAngle - 180;
                                angleInRadian = (Math.PI / 180) * angle;
                                radius += tb.TextBlockDesiredSize.Width + 3;
                                angle = (angleInRadian - Math.PI) * (180 / Math.PI);
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                            else if (dataPoint.LabelAngle >= -90 && dataPoint.LabelAngle < 0)
                            {
                                //radius += 3;
                                angle = dataPoint.LabelAngle;
                                angleInRadian = (Math.PI / 180) * angle;
                                ColumnChart.SetRotation(radius, angle, angleInRadian, centerOfRotation, labelLeft, labelTop, tb);
                            }
                        }
                    }
                }

                if (autoLabelStyle != dataPoint.LabelStyle)
                {
                    tb.TextElement.Foreground = Chart.CalculateDataPointLabelFontColor(dataPoint.Chart as Chart, dataPoint, dataPoint.LabelFontColor, (dataPoint.InternalYValue <= 0 ? LabelStyles.OutSide : autoLabelStyle));
                }

                dataPoint.LabelVisual = tb.Visual;

                dataPoint.LabelVisual.Width = tb.TextBlockDesiredSize.Width;
                dataPoint.LabelVisual.Height = tb.TextBlockDesiredSize.Height;

                labelCanvas.Children.Add(tb.Visual);
            }

            return retVal;
        }
Exemple #26
0
        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 = CalculateDataPointWidth(dsFaces.Visual.Width, dsFaces.Visual.Height, chart);
            
            switch (property)
            {   
                case VcProperties.BorderThickness:
                      ApplyOrUpdateBorder(dataPoint, dataPointWidth);
                      ApplyOrRemoveBevel(dataPoint, dataPointWidth);
                    break;

                case VcProperties.BorderStyle:
                    ApplyOrUpdateBorder(dataPoint, dataPointWidth);
                    break;

                case VcProperties.BorderColor:
                    ApplyOrUpdateBorder(dataPoint, dataPointWidth);
                    break;

                case VcProperties.Bevel:
                    ApplyOrRemoveBevel(dataPoint, dataPointWidth);
                    break;

                case VcProperties.Color:
                case VcProperties.PriceUpColor:
                case VcProperties.PriceDownColor:
                    ApplyOrUpdateColorForACandleStick(dataPoint);
                    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:
                    CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                    break;


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

                case VcProperties.LightingEnabled:
                    ApplyOrUpdateColorForACandleStick(dataPoint);
                    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:
                    ApplyOrRemoveShadow(dataPoint, 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);
                    CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                    break;

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

                case VcProperties.Enabled:
                    CreateOrUpdateACandleStick(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)
                            CreateAndPositionLabel(dsFaces.LabelCanvas, dataPoint);
                    }

                    if (dataPoint.Parent.SelectionEnabled && dataPoint.Selected)
                        dataPoint.Select(true);
                    
                        break;
            }
        }
Exemple #27
0
        private static void UpdateXAndYValue(DataPoint dataPoint, Canvas line2dLabelCanvas)
        {
            Boolean isAnimationEnabled = (Boolean)(dataPoint.Chart as Chart).AnimatedUpdate;

            if (!(Boolean)dataPoint.Enabled || dataPoint.Faces == null)
                return;

            Chart chart = dataPoint.Chart as Chart;
            DataSeries dataSeries = dataPoint.Parent;
            dataSeries._movingMarker.Visibility = Visibility.Collapsed;

            Axis axisX = dataSeries.PlotGroup.AxisX;
            Axis axisY = dataSeries.PlotGroup.AxisY;

            Marker dataPointMarker = dataPoint.Marker;
            Marker legendMarker = dataPoint.LegendMarker;
            
            Double height = chart.ChartArea.ChartVisualCanvas.Height;
            Double width = chart.ChartArea.ChartVisualCanvas.Width;

            Double x = Graphics.ValueToPixelPosition(0, width, axisX.InternalAxisMinimum, axisX.InternalAxisMaximum, dataPoint.InternalXValue);
            Double y = Graphics.ValueToPixelPosition(height, 0, axisY.InternalAxisMinimum, axisY.InternalAxisMaximum, dataPoint.InternalYValue);

            //Get coordinates of the previous DataPoint
            Double xPrevious = x;
            Double yPrevious = y;

            if (dataPoint.Faces.PreviousDataPoint != null)  //If previous DataPoint is present
            {
                xPrevious = Graphics.ValueToPixelPosition(0, width, axisX.InternalAxisMinimum, axisX.InternalAxisMaximum, dataPoint.Faces.PreviousDataPoint.InternalXValue);
                yPrevious = Graphics.ValueToPixelPosition(height, 0, axisY.InternalAxisMinimum, axisY.InternalAxisMaximum, dataPoint.Faces.PreviousDataPoint.InternalYValue);
            }

            //Gets coordinates of the DataPoint next to current DataPoint
            Double xNext = x;
            Double yNext = y;
            
            if (dataPoint.Faces.NextDataPoint != null)  //If next DataPoint is present
            {
                xNext = Graphics.ValueToPixelPosition(0, width, axisX.InternalAxisMinimum, axisX.InternalAxisMaximum, dataPoint.Faces.NextDataPoint.InternalXValue);
                yNext = Graphics.ValueToPixelPosition(height, 0, axisY.InternalAxisMinimum, axisY.InternalAxisMaximum, dataPoint.Faces.NextDataPoint.InternalYValue);
            }

            dataPoint._visualPosition = new Point(x, y);
            Point newMarkerPosition = new Point();
            Point newLabelPosition = new Point();

            if (dataPointMarker != null)
                newMarkerPosition = dataPointMarker.CalculateActualPosition(x, y, new Point(0.5, 0.5));

            if ((Boolean)dataPoint.LabelEnabled)
            {
                if (isAnimationEnabled && dataPoint.LabelVisual != null)
                {
                    dataPoint._oldLabelPosition = new Point((Double)dataPoint.LabelVisual.GetValue(Canvas.LeftProperty), (Double)dataPoint.LabelVisual.GetValue(Canvas.TopProperty));
                    newLabelPosition = CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, x, y, ref line2dLabelCanvas, false);

                    dataPoint.LabelVisual.SetValue(Canvas.TopProperty, dataPoint._oldLabelPosition.Y);
                    dataPoint.LabelVisual.SetValue(Canvas.LeftProperty, dataPoint._oldLabelPosition.X);
                }
                else
                    CreateLabel4LineDataPoint(dataPoint, width, height, dataPoint.InternalYValue >= 0, x, y, ref line2dLabelCanvas, true);
            }

            if (!isAnimationEnabled)
            {
                if (dataPointMarker != null && dataPointMarker.Visual != null)
                {
                    dataPointMarker.Visual.SetValue(Canvas.TopProperty, newMarkerPosition.Y);
                    dataPointMarker.Visual.SetValue(Canvas.LeftProperty, newMarkerPosition.X);
                }
            }

            DependencyObject target, shadowTarget = null;    // Target object
            Point oldPoint = new Point();                    // Old Position
            Point newPoint = new Point();                    // New Position 
            Point shadowOldPoint = new Point();

            // Collect reference of line geometry object
            LineSegment lineSeg1 = dataPoint.Faces.Parts[0] as LineSegment;     //Line Segment from previous DataPoint to Step point.
            LineSegment lineSeg2 = dataPoint.Faces.Parts[1] as LineSegment;     //Line Segment from Step point to the current DataPoint.
            LineSegment nextLineSeg1 = lineSeg2;                                //Line Segment from current DataPoint to next Step point.
            
            if (dataPoint.Faces.NextDataPoint != null)      //If next DataPoint is present
            {
                nextLineSeg1 = dataPoint.Faces.NextDataPoint.Faces.Parts[0] as LineSegment;
            }

            //If previous Data point is not present, Faces[1] is PathFigure, else Faces[2] is the PathFigure
            PathFigure pathFigure = dataPoint.Faces.Parts[1] as PathFigure;     
            if (dataPoint.Faces.PreviousDataPoint != null)
            {
                pathFigure = dataPoint.Faces.Parts[2] as PathFigure;
            }

            LineSegment shadowLineSeg1;                         //Shadow Line Segment from previous DataPoint to Step point.
            LineSegment shadowLineSeg2;                         //Shadow Line Segment from Step point to the current DataPoint.
            LineSegment nextShadowLineSeg1;                     //Shadow Line Segment from current DataPoint to next Step point.

            PathFigure shadowPathFigure;

            if (!VisifireControl.IsMediaEffectsEnabled)
            {
                // For line shadow
                if ((Boolean)dataPoint.Parent.ShadowEnabled)
                {
                    shadowLineSeg1 = dataPoint.ShadowFaces.Parts[0] as LineSegment;
                    shadowLineSeg2 = dataPoint.ShadowFaces.Parts[1] as LineSegment;

                    nextShadowLineSeg1 = shadowLineSeg2;
                    if (dataPoint.Faces.NextDataPoint != null)
                    {
                        nextShadowLineSeg1 = dataPoint.Faces.NextDataPoint.ShadowFaces.Parts[0] as LineSegment;
                    }

                    shadowPathFigure = dataPoint.ShadowFaces.Parts[1] as PathFigure;
                    if (dataPoint.Faces.PreviousDataPoint != null)
                    {
                        pathFigure = dataPoint.ShadowFaces.Parts[2] as PathFigure;
                    }

                    if (shadowLineSeg1 == null)
                    {
                        shadowOldPoint = shadowPathFigure.StartPoint;
                        shadowTarget = shadowPathFigure;
                        if (!isAnimationEnabled)
                        {
                            shadowPathFigure.StartPoint = new Point(x, y);
                            nextShadowLineSeg1.Point = new Point(xNext, y);
                        }
                    }
                    else
                    {
                        shadowTarget = shadowLineSeg2;
                        shadowOldPoint = shadowLineSeg2.Point;
                        if (!isAnimationEnabled)
                        {
                            shadowLineSeg1.Point = new Point(x, yPrevious);
                            shadowLineSeg2.Point = new Point(x, y);
                            nextShadowLineSeg1.Point = new Point(xNext, y);
                        }
                    }
                }
            }

            if (lineSeg1 == null)
            {
                target = pathFigure;

                if (isAnimationEnabled)
                {
                    if (dataPoint.Storyboard != null)
                        dataPoint.Storyboard.Pause();

                    oldPoint = pathFigure.StartPoint;
                    // pathFigure.StartPoint = new Point(x, y);
                    
                }
                else
                {
                    pathFigure.StartPoint = new Point(x, y);
                    
                    if(nextLineSeg1 != null)
                        nextLineSeg1.Point = new Point(xNext, y);
                }
                    
            }
            else
            {
                target = lineSeg2;
                oldPoint = lineSeg2.Point;

                if (isAnimationEnabled)
                {
                    if (dataPoint.Storyboard != null)
                        dataPoint.Storyboard.Pause();

                    // oldPoint = lineSeg2.Point;
                }
                else
                {
                    lineSeg1.Point = new Point(x, yPrevious);
                    lineSeg2.Point = new Point(x, y);
                    nextLineSeg1.Point = new Point(xNext, y);
                }
            }

            if (isAnimationEnabled)
            {
                #region Apply Animation to the DataPoint

                Storyboard storyBorad = new Storyboard();

                newPoint = new Point(x, y);
                target = pathFigure;
                if (lineSeg2 != null)
                {
                    target = lineSeg2;
                }

                //Animate the current data point.
                PointAnimation pointAnimation2 = new PointAnimation();
                pointAnimation2.From = oldPoint;
                pointAnimation2.To = newPoint;
                pointAnimation2.SpeedRatio = 2;
                pointAnimation2.Duration = new Duration(new TimeSpan(0, 0, 1));

                Storyboard.SetTarget(pointAnimation2, target);
                Storyboard.SetTargetProperty(pointAnimation2, (lineSeg2 != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
                Storyboard.SetTargetName(pointAnimation2, (String)target.GetValue(FrameworkElement.NameProperty));
                storyBorad.Children.Add(pointAnimation2);

                //Animate the Step point next to current DataPoint
                PointAnimation pointAnimation3 = new PointAnimation();
                pointAnimation3 = pointAnimation2;
                if (dataPoint.Faces.NextDataPoint != null)
                {
                    newPoint = new Point(xNext, y);
                    target = nextLineSeg1;
                    pointAnimation3 = new PointAnimation();
                    pointAnimation3.From = nextLineSeg1.Point;
                    pointAnimation3.To = newPoint;
                    pointAnimation3.SpeedRatio = 2;
                    pointAnimation3.Duration = new Duration(new TimeSpan(0, 0, 1));

                    Storyboard.SetTarget(pointAnimation3, target);
                    Storyboard.SetTargetProperty(pointAnimation3, (nextLineSeg1 != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
                    Storyboard.SetTargetName(pointAnimation3, (String)target.GetValue(FrameworkElement.NameProperty));
                    storyBorad.Children.Add(pointAnimation3);
                }

                if (!VisifireControl.IsMediaEffectsEnabled)
                {
                    if (shadowTarget != null)
                    {

                        shadowLineSeg1 = dataPoint.ShadowFaces.Parts[0] as LineSegment;
                        shadowLineSeg2 = dataPoint.ShadowFaces.Parts[1] as LineSegment;
                        nextShadowLineSeg1 = shadowLineSeg2;
                        if (dataPoint.Faces.NextDataPoint != null)
                        {
                            nextShadowLineSeg1 = dataPoint.Faces.NextDataPoint.ShadowFaces.Parts[0] as LineSegment;
                        }

                        shadowPathFigure = dataPoint.ShadowFaces.Parts[1] as PathFigure;
                        if (dataPoint.Faces.PreviousDataPoint != null)
                        {
                            pathFigure = dataPoint.ShadowFaces.Parts[2] as PathFigure;
                        }

                        shadowTarget = shadowPathFigure;
                        if (shadowLineSeg1 != null)
                        {
                            shadowTarget = shadowLineSeg2;
                        }

                        newPoint = new Point(x, y);
                        PointAnimation pointAnimationS2 = new PointAnimation();
                        pointAnimationS2.From = shadowOldPoint;
                        pointAnimationS2.To = newPoint;
                        pointAnimationS2.SpeedRatio = 2;
                        pointAnimationS2.Duration = new Duration(new TimeSpan(0, 0, 1));

                        //shadowTarget.SetValue(FrameworkElement.NameProperty, "ShadowSegment_" + dataPoint.Name);

                        Storyboard.SetTarget(pointAnimationS2, shadowTarget);
                        Storyboard.SetTargetProperty(pointAnimationS2, (shadowLineSeg2 != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
                        Storyboard.SetTargetName(pointAnimationS2, (String)shadowTarget.GetValue(FrameworkElement.NameProperty));

                        storyBorad.Children.Add(pointAnimationS2);

                        PointAnimation pointAnimationS3 = new PointAnimation();
                        pointAnimationS3 = pointAnimationS2;
                        if (dataPoint.Faces.NextDataPoint != null)
                        {
                            newPoint = new Point(xNext, y);
                            shadowTarget = nextShadowLineSeg1;
                            pointAnimationS3 = new PointAnimation();
                            pointAnimationS3.From = nextShadowLineSeg1.Point;
                            pointAnimationS3.To = newPoint;
                            pointAnimationS3.SpeedRatio = 2;
                            pointAnimationS3.Duration = new Duration(new TimeSpan(0, 0, 1));

                            //shadowTarget.SetValue(FrameworkElement.NameProperty, "ShadowSegment_" + dataPoint.Name);

                            Storyboard.SetTarget(pointAnimationS3, shadowTarget);
                            Storyboard.SetTargetProperty(pointAnimationS3, (nextShadowLineSeg1 != null) ? new PropertyPath("Point") : new PropertyPath("StartPoint"));
                            Storyboard.SetTargetName(pointAnimationS3, (String)shadowTarget.GetValue(FrameworkElement.NameProperty));
                            storyBorad.Children.Add(pointAnimationS3);
                        }

#if WPF
                        if (shadowLineSeg1 != null && nextShadowLineSeg1 != null)
                        {
                            (shadowLineSeg2 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimationS2);
                            (nextShadowLineSeg1 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimationS3);
                        }
                        else if (nextShadowLineSeg1 == null && shadowLineSeg1 != null)
                        {
                            (shadowLineSeg2 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimationS2);
                        }
                        else
                        {
                            (shadowPathFigure as PathFigure).BeginAnimation(PathFigure.StartPointProperty, pointAnimationS2);
                            (nextShadowLineSeg1 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimationS3);
                        }
#endif
                    }
                }

                #endregion

                #region Attach Animation with Marker

                FrameworkElement marker = dataPoint.Marker.Visual;

                if (marker != null)
                {
                    // Animation for (Canvas.Top) property
                    DoubleAnimation da = new DoubleAnimation()
                    {
                        From = (Double)marker.GetValue(Canvas.LeftProperty),
                        To = newMarkerPosition.X,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, marker);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                    Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                    // Animation for (Canvas.Top) property
                    da = new DoubleAnimation()
                    {
                        From = (Double)marker.GetValue(Canvas.TopProperty),
                        To = newMarkerPosition.Y,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, marker);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                    Storyboard.SetTargetName(da, (String)marker.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);
                }

                #endregion

                #region Attach Animation with Label

                FrameworkElement label = dataPoint.LabelVisual;

                if (label != null)
                {
                    // Animation for (Canvas.Top) property
                    DoubleAnimation da = new DoubleAnimation()
                    {
                        From = dataPoint._oldLabelPosition.X,
                        To = newLabelPosition.X,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, label);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Left)"));
                    Storyboard.SetTargetName(da, (String)label.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                    // Animation for (Canvas.Top) property
                    da = new DoubleAnimation()
                    {
                        From = dataPoint._oldLabelPosition.Y,
                        To = newLabelPosition.Y,
                        Duration = new Duration(new TimeSpan(0, 0, 1)),
                        SpeedRatio = 2
                    };

                    Storyboard.SetTarget(da, label);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(Canvas.Top)"));
                    Storyboard.SetTargetName(da, (String)label.GetValue(FrameworkElement.NameProperty));

                    storyBorad.Children.Add(da);

                }

                #endregion

                dataPoint.Storyboard = storyBorad;
#if WPF
                if (lineSeg1 != null && nextLineSeg1 != null)
                {    
                    (lineSeg2 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation2);
                    (nextLineSeg1 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation3);
                }
                else if (nextLineSeg1 == null && lineSeg1 != null)
                {
                    (lineSeg2 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation2);
                }
                else
                {
                    (pathFigure as PathFigure).BeginAnimation(PathFigure.StartPointProperty, pointAnimation2);
                    (nextLineSeg1 as LineSegment).BeginAnimation(LineSegment.PointProperty, pointAnimation3);
                }
   
#endif
                // Start the animation
                storyBorad.Begin();
            }

            //chart.ChartArea.ChartVisualCanvas.Background = new SolidColorBrush(Colors.Blue);
            dataSeries.Faces.Visual.Width = chart.ChartArea.ChartVisualCanvas.Width;
            dataSeries.Faces.Visual.Height = chart.ChartArea.ChartVisualCanvas.Height;

            dataSeries.Faces.LabelCanvas.Width = chart.ChartArea.ChartVisualCanvas.Width;
            dataSeries.Faces.LabelCanvas.Height = chart.ChartArea.ChartVisualCanvas.Height;

            // Update ToolTip Text
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);

            if (dataSeries._movingMarker != null)
                dataSeries._movingMarker.Visibility = Visibility.Collapsed;

            chart._toolTip.Hide();

            if (dataSeries.ToolTipElement != null)
                dataSeries.ToolTipElement.Hide();

            chart.ChartArea.DisableIndicators();

            if (dataSeries.Faces != null)
            {
                RectangleGeometry clipRectangle = new RectangleGeometry();

                Double depth3d = chart.ChartArea.PLANK_DEPTH / (chart.PlotDetails.Layer3DCount == 0 ? 1 : chart.PlotDetails.Layer3DCount) * (chart.View3D ? 1 : 0);

                Double clipLeft = 0;
                Double clipTop = -depth3d - 4;
                Double clipWidth = width + depth3d;
                Double clipHeight = height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10;

                AreaChart.GetClipCoordinates(chart, ref clipLeft, ref clipTop, ref clipWidth, ref clipHeight, dataSeries.PlotGroup.MinimumX, dataSeries.PlotGroup.MaximumX);

                clipRectangle.Rect = new Rect(clipLeft, clipTop, clipWidth, clipHeight);

                if (dataSeries.Faces.LabelCanvas != null && dataSeries.Faces.LabelCanvas.Parent != null)
                    (dataSeries.Faces.LabelCanvas.Parent as Canvas).Clip = clipRectangle;

                clipRectangle = new RectangleGeometry();
                clipRectangle.Rect = new Rect(0, -depth3d - 4, width + depth3d, height + chart.ChartArea.PLANK_DEPTH + chart.ChartArea.PLANK_THICKNESS + 10);

                if (dataSeries.Faces.Visual != null)
                    (dataSeries.Faces.Visual.Parent as Canvas).Clip = clipRectangle;
            }

        }
Exemple #28
0
        private static void CreateOrUpdateAPointDataPoint(Canvas bubleChartCanvas, DataPoint dataPoint, Double minimumZVal, Double maximumZVal, Double plotWidth, Double plotHeight)
        {
            Faces dpFaces = dataPoint.Faces;

            // Remove preexisting dataPoint visual and label visual
            if (dpFaces != null && dpFaces.Visual != null && bubleChartCanvas == dpFaces.Visual.Parent)
            {   
                bubleChartCanvas.Children.Remove(dataPoint.Faces.Visual);
                // dpFaces = null;
            }

            dataPoint.Faces = null;

            if (Double.IsNaN(dataPoint.InternalYValue) || (dataPoint.Enabled == false))
                return;

            Chart chart = dataPoint.Chart as Chart;

            PlotGroup plotGroup = dataPoint.Parent.PlotGroup;

            Canvas dataPointVisual = new Canvas();

            Faces bubbleFaces = new Faces();

            Double xPosition = Graphics.ValueToPixelPosition(0, plotWidth, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, dataPoint.InternalXValue);
            Double yPosition = Graphics.ValueToPixelPosition(plotHeight, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, dataPoint.InternalYValue);

            Brush markerColor = dataPoint.Color;
            markerColor = (chart.View3D ? Graphics.Get3DBrushLighting(markerColor, (Boolean)dataPoint.LightingEnabled) : ((Boolean)dataPoint.LightingEnabled ? Graphics.GetLightingEnabledBrush(markerColor, "Linear", null) : markerColor));
            
            String labelText = (Boolean)dataPoint.LabelEnabled ? dataPoint.TextParser(dataPoint.LabelText) : "";

            Marker marker = new Marker((MarkerTypes)dataPoint.MarkerType, 1, new Size(6,6), false, markerColor, labelText);
            dataPoint.Marker = marker;

            ApplyZValue(dataPoint, minimumZVal, maximumZVal, plotWidth, plotHeight);
                       
            marker.ShadowEnabled = (Boolean)dataPoint.ShadowEnabled;

            if (dataPoint.BorderColor != null)
                marker.BorderColor = dataPoint.BorderColor;

            marker.TextBackground = dataPoint.LabelBackground;
            marker.BorderThickness = ((Thickness)dataPoint.MarkerBorderThickness).Left;
            marker.TextAlignmentX = AlignmentX.Center;
            marker.TextAlignmentY = AlignmentY.Center;
            marker.Tag = new ElementData() { Element = dataPoint };

            Double gap = ((Double)dataPoint.MarkerScale * (Double)dataPoint.MarkerSize) / 2;

            if (!String.IsNullOrEmpty(labelText))
            {
                marker.FontColor = Chart.CalculateDataPointLabelFontColor(chart, dataPoint, dataPoint.LabelFontColor, LabelStyles.OutSide);
                marker.FontSize = (Double)dataPoint.LabelFontSize;
                marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
                marker.FontFamily = dataPoint.LabelFontFamily;
                marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
                marker.TextBackground = dataPoint.LabelBackground;

                marker.TextAlignmentX = AlignmentX.Center;
                marker.TextAlignmentY = AlignmentY.Center;

                if (!Double.IsNaN(dataPoint.LabelAngle) && dataPoint.LabelAngle != 0)
                {
                    marker.LabelAngle = dataPoint.LabelAngle;
                    marker.TextOrientation = Orientation.Vertical;

                    marker.TextAlignmentX = AlignmentX.Center;
                    marker.TextAlignmentY = AlignmentY.Center;

                    marker.LabelStyle = (LabelStyles)dataPoint.LabelStyle;
                }

                marker.CreateVisual();

                if (Double.IsNaN(dataPoint.LabelAngle) || dataPoint.LabelAngle == 0)
                {
                    if (yPosition - gap < 0 && (yPosition - marker.TextBlockSize.Height / 2) < 0)
                        marker.TextAlignmentY = AlignmentY.Bottom;
                    else if (yPosition + gap > plotHeight && (yPosition + marker.TextBlockSize.Height / 2) > plotHeight)
                        marker.TextAlignmentY = AlignmentY.Top;

                    if (xPosition - gap < 0 && (xPosition - marker.TextBlockSize.Width / 2) < 0)
                        marker.TextAlignmentX = AlignmentX.Right;
                    else if (xPosition + gap > plotWidth && (xPosition + marker.TextBlockSize.Width / 2) > plotWidth)
                        marker.TextAlignmentX = AlignmentX.Left;
                }
            }

            marker.PixelLavelShadow = false; // pixelLavelShadow;
            marker.CreateVisual();

            UpdateBubblePositionAccording2XandYValue(dataPoint, plotWidth, plotHeight, false, 0, 0);
            bubleChartCanvas.Children.Add(marker.Visual);
            
            bubbleFaces.Parts.Add(marker.MarkerShape);
            bubbleFaces.VisualComponents.Add(marker.Visual);
            bubbleFaces.BorderElements.Add(marker.MarkerShape);

            bubbleFaces.Visual = marker.Visual;
            dataPoint.Faces = bubbleFaces;

            dataPoint.Faces.Visual.Opacity = dataPoint.Opacity * dataPoint.Parent.Opacity;
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint);
            dataPoint.AttachEvent2DataPointVisualFaces(dataPoint.Parent);
            dataPoint._parsedToolTipText = dataPoint.TextParser(dataPoint.ToolTipText);
            dataPoint.AttachToolTip(chart, dataPoint, dataPoint.Faces.VisualComponents);
            dataPoint.AttachHref(chart, dataPoint.Faces.VisualComponents, dataPoint.Href, (HrefTargets)dataPoint.HrefTarget);
            dataPoint.SetCursor2DataPointVisualFaces();

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