Пример #1
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);
        }
Пример #2
0
 public LegendEntry(Marker marker, List<String> labels, List<HorizontalAlignment> xAlignments)
 {   
     Marker = marker;
     Labels = labels;
     XAlignments = xAlignments;
 }
Пример #3
0
 /// <summary>
 /// Apply Opacity animation to a Marker
 /// </summary>
 /// <param name="marker">Marker to animate</param>
 /// <param name="parentObj">Storyboard parent Object</param>
 /// <param name="storyboard">Storyboard reference</param>
 /// <param name="beginTime">Animation begin time</param>
 /// <param name="targetValue">Target opacity value</param>
 /// <returns>Storyboard</returns>
 internal static Storyboard ApplyOpacityAnimation(Marker marker, FrameworkElement parentObj, Storyboard storyboard, Double beginTime, Double targetValue)
 {   
     if (marker != null && parentObj != null)
         return ApplyOpacityAnimation(marker.Visual, parentObj, storyboard, beginTime, 0.75, 0,targetValue);
     else
         return storyboard;
 }
Пример #4
0
        /// <summary>
        /// Customize the marker for legend in Line chart
        /// </summary>
        /// <param name="marker"></param>
        /// <returns></returns>
        private Canvas GetNewMarkerForLineChart(Marker marker)
        {
            Canvas lineMarker = new Canvas();
            Line line = new Line() { Tag = marker.Tag };

            line.Margin = new Thickness(EntryMargin);
            line.Stroke = (marker.BorderColor);

            Double height = marker.TextBlockSize.Height > marker.MarkerSize.Height ? marker.TextBlockSize.Height : marker.MarkerSize.Height;
            lineMarker.Height = marker.MarkerActualSize.Height;

            line.X1 = 0;
            line.X2 = ENTRY_SYMBOL_LINE_WIDTH;
            line.Y1 = 0;
            line.Y2 = 0;
            line.Width = ENTRY_SYMBOL_LINE_WIDTH;

            lineMarker.Width = marker.MarkerActualSize.Width + ENTRY_SYMBOL_LINE_WIDTH / 2;

            line.StrokeDashArray = ApplyLineStyleForMarkerOfLegendEntry(line, marker.DataSeriesOfLegendMarker.LineStyle.ToString());

            lineMarker.Children.Add(line);

            lineMarker.Children.Add(marker.Visual);

            if (!(InternalVerticalAlignment == VerticalAlignment.Center && (InternalHorizontalAlignment == HorizontalAlignment.Left || InternalHorizontalAlignment == HorizontalAlignment.Right)))
            {
                line.Margin = new Thickness(ENTRY_SYMBOL_LINE_WIDTH / 2, marker.Visual.Margin.Top, marker.Visual.Margin.Right, marker.Visual.Margin.Bottom);
                marker.Visual.Margin = new Thickness(ENTRY_SYMBOL_LINE_WIDTH / 2, marker.Visual.Margin.Top, marker.Visual.Margin.Right, marker.Visual.Margin.Bottom);
            }

#if WPF
            line.SetValue(Canvas.TopProperty, height/2 );
#else
            line.Height = 8;
            line.SetValue(Canvas.TopProperty, (height / 2) + .4876);
#endif

            line.SetValue(Canvas.LeftProperty, (Double)(-marker.MarkerSize.Width / 2) - .4876);

            return lineMarker;
        }
Пример #5
0
 /// <summary>
 /// Apply font properties of a marker
 /// </summary>
 /// <param name="marker">Marker</param>
 private void ApplyFontPropertiesOfMarkerAsSymbol(Marker marker)
 {
     marker.FontFamily = InternalFontFamily;
     marker.FontStyle = InternalFontStyle;
     marker.FontWeight = InternalFontWeight;
     marker.FontSize = InternalFontSize;
     marker.FontColor = Charts.Chart.CalculateFontColor((Chart as Chart), Background, FontColor, this.DockInsidePlotArea);
 }
Пример #6
0
        /// <summary>
        /// Create new Marker
        /// </summary>
        /// <param name="columnParams">Column parameters</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="markerSize">Marker size</param>
        /// <param name="labelText">Label text</param>
        /// <returns>Marker</returns>
        internal static Marker CreateNewMarker(DataPoint dataPoint, Size markerSize, String labelText)
        {   
            Boolean markerBevel = false;

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

            marker.MarkerSize = markerSize;
            marker.BorderColor = dataPoint.MarkerBorderColor;
            marker.BorderThickness = dataPoint.MarkerBorderThickness.Value.Left;
            marker.MarkerType = (MarkerTypes)dataPoint.MarkerType;
            marker.FontColor = dataPoint.LabelFontColor;
            marker.FontFamily = dataPoint.LabelFontFamily;
            marker.FontSize = (Double)dataPoint.LabelFontSize;
            marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
            marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
            marker.TextBackground = dataPoint.LabelBackground;

            return marker;
        }
Пример #7
0
        /// <summary>
        /// Create new Marker
        /// </summary>
        /// <param name="chart">Chart</param>
        /// <param name="dataPoint">DataPoint</param>
        /// <param name="markerSize">Marker Size</param>
        /// <param name="labelText">Label text</param>
        /// <returns>Marker</returns>
        internal static Marker CreateNewMarker(Chart chart, DataPoint dataPoint, Size markerSize, String labelText)
        {
            Boolean markerBevel = false;
            Marker marker = new Marker((MarkerTypes)dataPoint.MarkerType, (Double)dataPoint.MarkerScale, markerSize, markerBevel, dataPoint.MarkerColor, labelText);

            marker.MarkerSize = markerSize;
            marker.BorderColor = dataPoint.MarkerBorderColor;
            marker.BorderThickness = ((Thickness)dataPoint.MarkerBorderThickness).Left;
            marker.FontColor = Chart.CalculateDataPointLabelFontColor(chart, dataPoint, dataPoint.LabelFontColor, LabelStyles.OutSide);
            marker.FontFamily = dataPoint.LabelFontFamily;
            marker.FontSize = (Double)dataPoint.LabelFontSize;
            marker.FontStyle = (FontStyle)dataPoint.LabelFontStyle;
            marker.FontWeight = (FontWeight)dataPoint.LabelFontWeight;
            marker.TextBackground = dataPoint.LabelBackground;
            marker.MarkerFillColor = dataPoint.MarkerColor;
            marker.Tag = new ElementData() { Element = dataPoint };
            return marker;
        }
Пример #8
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);
        }