/* Copyright (C) 2008 Webyog Softworks Private Limited This file is a part of Visifire Charts. Visifire is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. You should have received a copy of the GNU General Public License along with Visifire Charts. If not, see . If GPL is not suitable for your products or company, Webyog provides Visifire under a flexible commercial license designed to meet your specific usage and distribution requirements. If you have already obtained a commercial license from Webyog, you can use this file under those license terms. */ #if WPF using System; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Shapes; using System.Windows.Media.Animation; #else using System; using System.Windows; using System.Linq; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; #endif using Visifire.Commons; using System.Windows.Data; using System.Collections.Generic; namespace Visifire.Charts { /// /// Visifire.Charts.DataPoint class /// #if SL [System.Windows.Browser.ScriptableType] #endif public class DataPoint : ObservableObject { #region Public Methods /// /// Initializes a new instance of the Visifire.Charts.DataPoint class /// public DataPoint() { ToolTipText = String.Empty; InternalXValue = Double.NaN; XValueType = ChartValueTypes.Numeric; //YValues = new DoubleCollection(); // Apply default style from generic #if WPF if (!_defaultStyleKeyApplied) { DefaultStyleKeyProperty.OverrideMetadata(typeof(DataPoint), new FrameworkPropertyMetadata(typeof(DataPoint))); _defaultStyleKeyApplied = true; } #else DefaultStyleKey = typeof(DataPoint); #endif } public override void Bind() { #if SL Binding b = new Binding("BorderThickness"); b.Source = this; this.SetBinding(InternalBorderThicknessProperty, b); b = new Binding("Opacity"); b.Source = this; this.SetBinding(InternalOpacityProperty, b); #endif } /// /// Set DateTime in AxisXLabel /// /// DataPoint /// Axis /// Axis labels private String FormatDate4Labels(DateTime dt, Axis axis) { String valueFormatString = axis.XValueType == ChartValueTypes.Date ? "M/d/yyyy" : axis.XValueType == ChartValueTypes.Time ? "h:mm:ss tt" : "M/d/yyyy h:mm:ss tt"; valueFormatString = String.IsNullOrEmpty(Parent.XValueFormatString) ? valueFormatString : Parent.XValueFormatString; return axis.AddPrefixAndSuffix(dt.ToString(valueFormatString, System.Globalization.CultureInfo.CurrentCulture)); } /// /// TextParser is used to parse ToolTipText /// /// String unParsed /// parsed as string public override string ParseToolTipText(string unParsed) { return _parsedToolTipText; } /// /// OnToolTipTextPropertyChanged call back virtual function /// /// New ToolTip value internal override void OnToolTipTextPropertyChanged(string newValue) { // base.OnToolTipTextPropertyChanged(newValue); if (Chart != null && _parsedToolTipText != null) { _parsedToolTipText = TextParser(newValue); } } /// /// Already parsed content /// internal String _parsedToolTipText = null; /// /// TextParser is used to parse text /// /// String unParsed /// parsed as string public override String TextParser(String unParsed) { if (string.IsNullOrEmpty(unParsed) || Enabled == false) return ""; String str = new String(unParsed.ToCharArray()); if (str.Contains("##XValue")) str = str.Replace("##XValue", "#XValue"); else { if (String.IsNullOrEmpty(_parent.XValueFormatString)) { if (Parent.PlotGroup != null) { if ((Chart as Chart).ChartArea.AxisX != null && (Chart as Chart).ChartArea.AxisX.XValueType != ChartValueTypes.Numeric) str = str.Replace("#XValue", FormatDate4Labels(Convert.ToDateTime(InternalXValueAsDateTime), (Chart as Chart).ChartArea.AxisX)); else if ((this.Parent.RenderAs == RenderAs.Pie || this.Parent.RenderAs == RenderAs.Doughnut || this.Parent.RenderAs == RenderAs.SectionFunnel || this.Parent.RenderAs == RenderAs.StreamLineFunnel) && (Parent.InternalXValueType != ChartValueTypes.Numeric)) { str = str.Replace("#XValue", FormatDate4Labels(Convert.ToDateTime(InternalXValueAsDateTime), Parent.PlotGroup.AxisX)); } else str = str.Replace("#XValue", Parent.PlotGroup.AxisX.GetFormattedString(InternalXValue)); } } else if (Parent.PlotGroup != null) { if ((Chart as Chart).ChartArea.AxisX != null && (Chart as Chart).ChartArea.AxisX.XValueType != ChartValueTypes.Numeric) str = str.Replace("#XValue", FormatDate4Labels(Convert.ToDateTime(InternalXValueAsDateTime), (Chart as Chart).ChartArea.AxisX)); else if ((this.Parent.RenderAs == RenderAs.Pie || this.Parent.RenderAs == RenderAs.Doughnut || this.Parent.RenderAs == RenderAs.SectionFunnel || this.Parent.RenderAs == RenderAs.StreamLineFunnel) && (Parent.InternalXValueType != ChartValueTypes.Numeric)) { str = str.Replace("#XValue", FormatDate4Labels(Convert.ToDateTime(InternalXValueAsDateTime), Parent.PlotGroup.AxisX)); } else str = str.Replace("#XValue", InternalXValue.ToString(Parent.XValueFormatString)); } } if (str.Contains("##YValue")) str = str.Replace("##YValue", "#YValue"); else { if (String.IsNullOrEmpty(_parent.YValueFormatString)) { if (Parent.PlotGroup != null) str = str.Replace("#YValue", Parent.PlotGroup.AxisY.GetFormattedString(InternalYValue)); } else str = str.Replace("#YValue", InternalYValue.ToString(Parent.YValueFormatString)); } if (str.Contains("##ZValue")) str = str.Replace("##ZValue", "#ZValue"); else { str = str.Replace("#ZValue", ZValue.ToString(Parent.ZValueFormatString)); } if (str.Contains("##Series")) str = str.Replace("##Series", "#Series"); else str = str.Replace("#Series", Parent.Name); if (str.Contains("##AxisXLabel")) str = str.Replace("##AxisXLabel", "#AxisXLabel"); else str = str.Replace("#AxisXLabel", String.IsNullOrEmpty(AxisXLabel) ? GetAxisXLabelString() : AxisXLabel); if (str.Contains("##Percentage")) str = str.Replace("##Percentage", "#Percentage"); else str = str.Replace("#Percentage", Percentage().ToString("#0.##")); if (str.Contains("##Sum")) str = str.Replace("##Sum", "#Sum"); else { if (Parent.PlotGroup != null && Parent.PlotGroup.XWiseStackedDataList != null && Parent.PlotGroup.XWiseStackedDataList.ContainsKey(InternalXValue)) { Double sum = 0; sum += Parent.PlotGroup.XWiseStackedDataList[InternalXValue].PositiveYValueSum; sum += Parent.PlotGroup.XWiseStackedDataList[InternalXValue].NegativeYValueSum; str = str.Replace("#Sum", Parent.PlotGroup.AxisY.GetFormattedString(sum)); //_stackSum[XValue].X contains sum of all data points with same X value } } if (_parent.RenderAs == RenderAs.Stock || _parent.RenderAs == RenderAs.CandleStick) { if (str.Contains("##High")) str = str.Replace("##High", "#High"); else { if (String.IsNullOrEmpty(_parent.YValueFormatString)) { if (Parent.PlotGroup != null && YValues != null && YValues.Length > 2) str = str.Replace("#High", Parent.PlotGroup.AxisY.GetFormattedString(YValues[2])); else str = str.Replace("#High", ""); } else { if (YValues != null && YValues.Length > 2) str = str.Replace("#High", YValues[2].ToString(Parent.YValueFormatString)); else str = str.Replace("#High", ""); } } if (str.Contains("##Low")) str = str.Replace("##Low", "#Low"); else { if (String.IsNullOrEmpty(_parent.YValueFormatString)) { if (Parent.PlotGroup != null && YValues != null && YValues.Length > 3) str = str.Replace("#Low", Parent.PlotGroup.AxisY.GetFormattedString(YValues[3])); else str = str.Replace("#Low", ""); } else { if (YValues != null && YValues.Length > 3) str = str.Replace("#Low", YValues[3].ToString(Parent.YValueFormatString)); else str = str.Replace("#Low", ""); } } if (str.Contains("##Open")) str = str.Replace("##Open", "#Open"); else { if (String.IsNullOrEmpty(_parent.YValueFormatString)) { if (Parent.PlotGroup != null && YValues != null && YValues.Length > 0) str = str.Replace("#Open", Parent.PlotGroup.AxisY.GetFormattedString(YValues[0])); else str = str.Replace("#Open", ""); } else { if (YValues != null && YValues.Length > 0) str = str.Replace("#Open", YValues[0].ToString(Parent.YValueFormatString)); else str = str.Replace("#Open", ""); } } if (str.Contains("##Close")) str = str.Replace("##Close", "#Close"); else { if (String.IsNullOrEmpty(_parent.YValueFormatString)) { if (Parent.PlotGroup != null && YValues != null && YValues.Length > 1) str = str.Replace("#Close", Parent.PlotGroup.AxisY.GetFormattedString(YValues[1])); else str = str.Replace("#Close", ""); } else { if (YValues != null && YValues.Length > 1) str = str.Replace("#Close", YValues[1].ToString(Parent.YValueFormatString)); else str = str.Replace("#Close", ""); } } } return GetFormattedMultilineText(str); } #endregion #region Public Properties /// /// Identifies the Visifire.Charts.DataPoint.Selected dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Selected dependency property. /// public static readonly DependencyProperty SelectedProperty = DependencyProperty.Register ("Selected", typeof(Boolean), typeof(DataPoint), new PropertyMetadata(OnSelectedChanged)); /// /// Identifies the Visifire.Charts.DataPoint.HrefTarget dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.HrefTarget dependency property. /// public static readonly DependencyProperty HrefTargetProperty = DependencyProperty.Register ("HrefTarget", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnHrefTargetChanged)); /// /// Identifies the Visifire.Charts.DataPoint.Href dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Href dependency property. /// public static readonly DependencyProperty HrefProperty = DependencyProperty.Register ("Href", typeof(String), typeof(DataPoint), new PropertyMetadata(OnHrefChanged)); #if WPF /// /// Identifies the Visifire.Charts.DataPoint.Opacity dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Opacity dependency property. /// public new static readonly DependencyProperty OpacityProperty = DependencyProperty.Register ("Opacity", typeof(Double), typeof(DataPoint), new PropertyMetadata(1.0, OnOpacityPropertyChanged)); #endif /// /// Identifies the Visifire.Charts.DataPoint.YValue dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.YValue dependency property. /// public static readonly DependencyProperty YValueProperty = DependencyProperty.Register ("YValue", typeof(Double), typeof(DataPoint), new PropertyMetadata(Double.NaN, OnYValuePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.YValues dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.YValues dependency property. /// public static readonly DependencyProperty YValuesProperty = DependencyProperty.Register ("YValues", typeof(Double[]), typeof(DataPoint), new PropertyMetadata(null, OnYValuesPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.XValue dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.XValue dependency property. /// public static readonly DependencyProperty XValueProperty = DependencyProperty.Register ("XValue", typeof(Object), typeof(DataPoint), new PropertyMetadata(OnXValuePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.ZValue dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.ZValue dependency property. /// public static readonly DependencyProperty ZValueProperty = DependencyProperty.Register ("ZValue", typeof(Double), typeof(DataPoint), new PropertyMetadata(Double.NaN, OnZValuePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.AxisXLabel dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.AxisXLabel dependency property. /// public static readonly DependencyProperty AxisXLabelProperty = DependencyProperty.Register ("AxisXLabel", typeof(String), typeof(DataPoint), new PropertyMetadata(OnAxisXLabelPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.Color dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Color dependency property. /// public static readonly DependencyProperty ColorProperty = DependencyProperty.Register ("Color", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnColorPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.Enabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Enabled dependency property. /// public static readonly DependencyProperty EnabledProperty = DependencyProperty.Register ("Enabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.Exploded dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.Exploded dependency property. /// public static readonly DependencyProperty ExplodedProperty = DependencyProperty.Register ("Exploded", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnExplodedPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LightingEnabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LightingEnabled dependency property. /// public static readonly DependencyProperty LightingEnabledProperty = DependencyProperty.Register ("LightingEnabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLightingEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.ShadowEnabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.ShadowEnabled dependency property. /// public static readonly DependencyProperty ShadowEnabledProperty = DependencyProperty.Register ("ShadowEnabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnShadowEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.ShowInLegend dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.ShowInLegend dependency property. /// public static readonly DependencyProperty ShowInLegendProperty = DependencyProperty.Register ("ShowInLegend", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnShowInLegendPropertychanged)); /// /// Identifies the Visifire.Charts.DataPoint.LegendText dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LegendText dependency property. /// public static readonly DependencyProperty LegendTextProperty = DependencyProperty.Register ("LegendText", typeof(String), typeof(DataPoint), new PropertyMetadata(OnLegendTextPropertychanged)); #if WPF /// /// Identifies the Visifire.Charts.DataPoint.BorderThickness dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.BorderThickness dependency property. /// public new static readonly DependencyProperty BorderThicknessProperty = DependencyProperty.Register ("BorderThickness", typeof(Thickness), typeof(DataPoint), new PropertyMetadata(OnBorderThicknessPropertyChanged)); #endif /// /// Identifies the Visifire.Charts.DataPoint.BorderColor dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.BorderColor dependency property. /// public static readonly DependencyProperty BorderColorProperty = DependencyProperty.Register ("BorderColor", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnBorderColorPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.BorderStyle dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.BorderStyle dependency property. /// public static readonly DependencyProperty BorderStyleProperty = DependencyProperty.Register ("BorderStyle", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnBorderStylePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.RadiusX dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.RadiusX dependency property. /// public static readonly DependencyProperty RadiusXProperty = DependencyProperty.Register ("RadiusX", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnRadiusXPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.RadiusY dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.RadiusY dependency property. /// public static readonly DependencyProperty RadiusYProperty = DependencyProperty.Register ("RadiusY", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnRadiusYPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelEnabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelEnabled dependency property. /// public static readonly DependencyProperty LabelEnabledProperty = DependencyProperty.Register ("LabelEnabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelText dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelText dependency property. /// public static readonly DependencyProperty LabelTextProperty = DependencyProperty.Register ("LabelText", typeof(String), typeof(DataPoint), new PropertyMetadata(OnLabelTextPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelFontFamily dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelFontFamily dependency property. /// public static readonly DependencyProperty LabelFontFamilyProperty = DependencyProperty.Register ("LabelFontFamily", typeof(FontFamily), typeof(DataPoint), new PropertyMetadata(OnLabelFontFamilyPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelFontSize dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelFontSize dependency property. /// public static readonly DependencyProperty LabelFontSizeProperty = DependencyProperty.Register ("LabelFontSize", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelFontSizePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelFontColor dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelFontColor dependency property. /// public static readonly DependencyProperty LabelFontColorProperty = DependencyProperty.Register ("LabelFontColor", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnLabelFontColorPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelFontWeight dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelFontWeight dependency property. /// public static readonly DependencyProperty LabelFontWeightProperty = DependencyProperty.Register ("LabelFontWeight", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelFontWeightPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelFontStyle dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelFontStyle dependency property. /// public static readonly DependencyProperty LabelFontStyleProperty = DependencyProperty.Register ("LabelFontStyle", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelFontStylePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelBackground dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelBackground dependency property. /// public static readonly DependencyProperty LabelBackgroundProperty = DependencyProperty.Register ("LabelBackground", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnLabelBackgroundPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelStyle dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelStyle dependency property. /// public static readonly DependencyProperty LabelStyleProperty = DependencyProperty.Register ("LabelStyle", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelStylePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelLineEnabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelLineEnabled dependency property. /// public static readonly DependencyProperty LabelLineEnabledProperty = DependencyProperty.Register ("LabelLineEnabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelLineEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelLineColor dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelLineColor dependency property. /// public static readonly DependencyProperty LabelLineColorProperty = DependencyProperty.Register ("LabelLineColor", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnLabelLineColorPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelLineThickness dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelLineThickness dependency property. /// public static readonly DependencyProperty LabelLineThicknessProperty = DependencyProperty.Register ("LabelLineThickness", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelLineThicknessPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelLineStyle dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelLineStyle dependency property. /// public static readonly DependencyProperty LabelLineStyleProperty = DependencyProperty.Register ("LabelLineStyle", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnLabelLineStylePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.LabelAngle dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.LabelAngle dependency property. /// public static readonly DependencyProperty LabelAngleProperty = DependencyProperty.Register ("LabelAngle", typeof(Double), typeof(DataPoint), new PropertyMetadata(Double.NaN, OnLabelAnglePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerEnabled dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerEnabled dependency property. /// public static readonly DependencyProperty MarkerEnabledProperty = DependencyProperty.Register ("MarkerEnabled", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnMarkerEnabledPropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerType dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerType dependency property. /// public static readonly DependencyProperty MarkerTypeProperty = DependencyProperty.Register ("MarkerType", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnMarkerTypePropertyChanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerBorderThickness dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerBorderThickness dependency property. /// public static readonly DependencyProperty MarkerBorderThicknessProperty = DependencyProperty.Register ("MarkerBorderThickness", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnMarkerBorderThicknessPropertychanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerBorderColor dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerBorderColor dependency property. /// public static readonly DependencyProperty MarkerBorderColorProperty = DependencyProperty.Register ("MarkerBorderColor", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnMarkerBorderColorPropertychanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerSize dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerSize dependency property. /// public static readonly DependencyProperty MarkerSizeProperty = DependencyProperty.Register ("MarkerSize", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnMarkerSizePropertychanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerColor dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerColor dependency property. /// public static readonly DependencyProperty MarkerColorProperty = DependencyProperty.Register ("MarkerColor", typeof(Brush), typeof(DataPoint), new PropertyMetadata(OnMarkerColorPropertychanged)); /// /// Identifies the Visifire.Charts.DataPoint.MarkerScale dependency property. /// /// /// The identifier for the Visifire.Charts.DataPoint.MarkerScale dependency property. /// public static readonly DependencyProperty MarkerScaleProperty = DependencyProperty.Register ("MarkerScale", typeof(Nullable), typeof(DataPoint), new PropertyMetadata(OnMarkerScalePropertychanged)); /// /// Get or set the HrefTarget property of DataPoint /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableHrefTargetsConverter))] #endif public Nullable HrefTarget { get { if ((Nullable)GetValue(HrefTargetProperty) == null && _parent != null) return _parent.HrefTarget; else return (Nullable)GetValue(HrefTargetProperty); } set { SetValue(HrefTargetProperty, value); } } /// /// Get or set the Selected property of DataPoint /// public Boolean Selected { get { if (Parent != null) return ((Boolean)GetValue(SelectedProperty) & Parent.SelectionEnabled); else return (Boolean)GetValue(SelectedProperty); } set { SetValue(SelectedProperty, value); } } /// /// Get or set the Href property of DataPoint /// public String Href { get { if (String.IsNullOrEmpty((String)GetValue(HrefProperty)) && _parent != null) return (String)Parent.GetValue(DataSeries.HrefProperty); else return (String)GetValue(HrefProperty); } set { SetValue(HrefProperty, value); } } /// /// Get or set the Opacity property /// public new Double Opacity { get { return (Double)GetValue(OpacityProperty); } set { #if SL if (Opacity != value) { InternalOpacity = value; SetValue(OpacityProperty, value); FirePropertyChanged("Opacity"); } #else SetValue(OpacityProperty, value); #endif } } /// /// Get or set the Cursor property /// public new Cursor Cursor { get { if (base.Cursor == null) return _parent.Cursor; else return base.Cursor; } set { if (base.Cursor != value) { base.Cursor = value; if (Faces != null || (this.Parent != null && this.Parent.Faces != null) || this.Marker != null) SetCursor2DataPointVisualFaces(); else FirePropertyChanged("Cursor"); } } } /// /// Get or set the value that will appear on Y-Axis for all charts. /// In the case of Pie and Doughnut, the YValue will be considered for calculating the percentages. /// [System.ComponentModel.TypeConverter(typeof(Converters.ValueConverter))] public Double YValue { get { return (Double)GetValue(YValueProperty); } set { SetValue(YValueProperty, value); } } [System.ComponentModel.TypeConverter(typeof(Converters.DoubleArrayConverter))] public Double[] YValues { get { return (Double[])GetValue(YValuesProperty); } set { SetValue(YValuesProperty, value); } } /// /// Get the YValue that will be used for Internal purpose. /// [System.ComponentModel.TypeConverter(typeof(Converters.ValueConverter))] internal Double InternalYValue { get { if ((Double.IsNaN(YValue) || Enabled == false) && Parent != null && (Parent.RenderAs == RenderAs.Area || Parent.RenderAs == RenderAs.StackedArea100 || Parent.RenderAs == RenderAs.StackedArea)) { return 0; } else return YValue; } } /// /// Get or set the value that will appear on X-Axis for all charts. /// // [System.ComponentModel.TypeConverter(typeof(Converters.ValueConverter))] public Object XValue { get { return GetValue(XValueProperty); } set { SetValue(XValueProperty, value); } } /// /// Type of scale used in axis /// internal ChartValueTypes XValueType { get; set; } /// /// Get or set the value that will appear for bubble charts only /// [System.ComponentModel.TypeConverter(typeof(Converters.ValueConverter))] public Double ZValue { get { return (Double)GetValue(ZValueProperty); } set { SetValue(ZValueProperty, value); } } /// /// Get or set the LabelAngle property /// public Double LabelAngle { get { if (Double.IsNaN((Double)GetValue(LabelAngleProperty)) && _parent != null) return _parent.LabelAngle; else return (Double)GetValue(LabelAngleProperty); } set { if (value > 90 || value < -90) throw (new Exception("Invalid property value:: LabelAngle should be greater than -90 and less than 90.")); SetValue(LabelAngleProperty, value); } } /// /// Label to be placed for the corresponding XValue in the AxisX /// public String AxisXLabel { get { return (String)GetValue(AxisXLabelProperty); } set { SetValue(AxisXLabelProperty, value); } } /// /// Get or set the color of the DataPoint /// public Brush Color { get { if ((Brush)GetValue(ColorProperty) == null) { if (_parent == null) return _internalColor; else return (_parent.Color == null) ? _internalColor : _parent.Color; } else return (Brush)GetValue(ColorProperty); } set { SetValue(ColorProperty, value); } } /// /// Enables or disables the DataPoint /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable Enabled { get { if ((Nullable)GetValue(EnabledProperty) == null && _parent != null) return Parent.Enabled; else return (Nullable)GetValue(EnabledProperty); } set { SetValue(EnabledProperty, value); } } /// /// Get or set the Exploded property. This is used in Pie/Doughnut charts. /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable Exploded { get { return (GetValue(ExplodedProperty) == null) ? ((_parent != null) ? _parent.Exploded : false) : (Boolean)GetValue(ExplodedProperty); } set { SetValue(ExplodedProperty, value); } } /// /// Get or set the LightingEnabled property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable LightingEnabled { get { if ((Nullable)GetValue(LightingEnabledProperty) == null && _parent != null) { return _parent.LightingEnabled; } else { return (Nullable)GetValue(LightingEnabledProperty); } } set { SetValue(LightingEnabledProperty, value); } } /// /// Get or set the ShadowEnabled property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable ShadowEnabled { get { if ((Nullable)GetValue(ShadowEnabledProperty) == null && _parent != null) { return _parent.ShadowEnabled; } else { return (Nullable)GetValue(ShadowEnabledProperty); } } set { SetValue(ShadowEnabledProperty, value); } } #region Label Properties /// /// Get or set the LabelEnabled property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable LabelEnabled { get { if (GetValue(LabelEnabledProperty) == null && _parent != null) return _parent.LabelEnabled; else return (Nullable)GetValue(LabelEnabledProperty); } set { SetValue(LabelEnabledProperty, value); } } /// /// Get or set the LabelText property /// public String LabelText { get { if (String.IsNullOrEmpty((String)GetValue(LabelTextProperty)) && _parent != null) return _parent.LabelText; else return (String)GetValue(LabelTextProperty); } set { SetValue(LabelTextProperty, value); } } /// /// Get or set the LabelFontFamily property /// public FontFamily LabelFontFamily { get { if (GetValue(LabelFontFamilyProperty) == null && _parent != null) return _parent.LabelFontFamily; else return (FontFamily)GetValue(LabelFontFamilyProperty); } set { SetValue(LabelFontFamilyProperty, value); } } /// /// GEt or set the LabelFontSize property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableDoubleConverter))] #endif public Nullable LabelFontSize { get { if ((Nullable)GetValue(LabelFontSizeProperty) != null) return (Nullable)GetValue(LabelFontSizeProperty); else if (_parent != null && _parent.LabelFontSize != 0) return _parent.LabelFontSize; else return 10; } set { SetValue(LabelFontSizeProperty, value); } } /// /// Get or set the LabelFontColor property /// public Brush LabelFontColor { get { if (GetValue(LabelFontColorProperty) == null && _parent != null) return _parent.LabelFontColor; else return (Brush)GetValue(LabelFontColorProperty); } set { SetValue(LabelFontColorProperty, value); } } /// /// Get or set the LabelFontWeight property /// #if SL [System.ComponentModel.TypeConverter(typeof(Visifire.Commons.Converters.FontWeightConverter))] #endif public Nullable LabelFontWeight { get { if ((Nullable)GetValue(LabelFontWeightProperty) == null && _parent != null) return _parent.LabelFontWeight; else return (Nullable)GetValue(LabelFontWeightProperty); } set { SetValue(LabelFontWeightProperty, value); } } /// /// Get or set the LabelFontStyle property /// #if SL [System.ComponentModel.TypeConverter(typeof(Visifire.Commons.Converters.FontStyleConverter))] #endif public Nullable LabelFontStyle { get { if ((Nullable)GetValue(LabelFontStyleProperty) == null && _parent != null) return _parent.LabelFontStyle; else return (Nullable)GetValue(LabelFontStyleProperty); } set { SetValue(LabelFontStyleProperty, value); } } /// /// Get or set the LabelBackground property /// public Brush LabelBackground { get { if (GetValue(LabelBackgroundProperty) == null && _parent != null) return _parent.LabelBackground; else return (Brush)GetValue(LabelBackgroundProperty); } set { SetValue(LabelBackgroundProperty, value); } } /// /// Get or set the LabelStyle property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableLabelStylesConverter))] #endif public Nullable LabelStyle { get { if ((Nullable)GetValue(LabelStyleProperty) == null && _parent != null) { IsLabelStyleSet = false; return _parent.LabelStyle; } else { IsLabelStyleSet = true; return (Nullable)GetValue(LabelStyleProperty); } } set { SetValue(LabelStyleProperty, value); } } /// /// Get or set the LabelLineEnabled property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable LabelLineEnabled { get { if (LabelEnabled != null && (Boolean)LabelEnabled) { Nullable retVal = null; if ((Nullable)GetValue(LabelLineEnabledProperty) == null) { if (_parent != null) { if ((_parent.RenderAs == RenderAs.Pie || _parent.RenderAs == RenderAs.Doughnut || _parent.RenderAs == RenderAs.StreamLineFunnel || _parent.RenderAs == RenderAs.SectionFunnel) && (LabelStyle == LabelStyles.OutSide)) //retVal = (_parent != null) ? _parent.LabelLineEnabled : null; retVal = (_parent.LabelLineEnabled != null) ? _parent.LabelLineEnabled : true; else retVal = false; } else retVal = false; } else retVal = (Nullable)GetValue(LabelLineEnabledProperty); //if(retVal == null && _parent != null) // retVal = ((_parent.RenderAs == RenderAs.Pie || _parent.RenderAs == RenderAs.Doughnut) && (LabelStyle == LabelStyles.OutSide)) ? true : false; return retVal; } return false; } set { SetValue(LabelLineEnabledProperty, value); } } //public Nullable LabelLineEnabled //{ // get // { // if (LabelEnabled != null && (Boolean)LabelEnabled) // { // Nullable retVal = null; // if ((Nullable)GetValue(LabelLineEnabledProperty) == null) // { // if (_parent != null) // { // if ((_parent.RenderAs == RenderAs.Pie || _parent.RenderAs == RenderAs.Doughnut) && (LabelStyle == LabelStyles.OutSide)) // retVal = (_parent.LabelLineEnabled != null) ? _parent.LabelLineEnabled : true; // else if (Chart != null && (Chart as Chart).PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) // retVal = (_parent.LabelLineEnabled != null) ? _parent.LabelLineEnabled : true; // else // retVal = false; // } // else // retVal = false; // } // else // retVal = (Nullable)GetValue(LabelLineEnabledProperty); // return retVal; // } // return false; // } // set // { // SetValue(LabelLineEnabledProperty, value); // } //} /// /// Get or set the LabelLineColor property /// public Brush LabelLineColor { get { if (GetValue(LabelLineColorProperty) == null && _parent != null) return _parent.LabelLineColor; else return (Brush)GetValue(LabelLineColorProperty); } set { SetValue(LabelLineColorProperty, value); } } /// /// Get or set the LabelLineThickness property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableDoubleConverter))] #endif public Nullable LabelLineThickness { get { if ((Nullable)GetValue(LabelLineThicknessProperty) != null) return (Double)GetValue(LabelLineThicknessProperty); else if (_parent != null && _parent.LabelLineThickness != 0) return _parent.LabelLineThickness; else return 0.5; } set { SetValue(LabelLineThicknessProperty, value); } } /// /// Get or set the LabelLineStyle property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableLineStylesConverter))] #endif public Nullable LabelLineStyle { get { if ((Nullable)GetValue(LabelLineStyleProperty) == null && _parent != null) return _parent.LabelLineStyle; else return (Nullable)GetValue(LabelLineStyleProperty); } set { SetValue(LabelLineStyleProperty, value); } } #endregion #region Marker Properties /// /// Get or set the MarkerEnabled property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable MarkerEnabled { get { if ((Nullable)GetValue(MarkerEnabledProperty) == null && _parent != null) return _parent.MarkerEnabled; else return (Nullable)GetValue(MarkerEnabledProperty); } set { SetValue(MarkerEnabledProperty, value); } } /// /// Get or set the MarkerStyle property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableMarkerTypesConverter))] #endif public Nullable MarkerType { get { if ((Nullable)GetValue(MarkerTypeProperty) == null && _parent != null) return _parent.MarkerType; else return (Nullable)GetValue(MarkerTypeProperty); } set { SetValue(MarkerTypeProperty, value); } } /// /// Get or set the MarkerBorderThickness property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableThicknessConverter))] #endif public Nullable MarkerBorderThickness { get { if ((Nullable)GetValue(MarkerBorderThicknessProperty) == null) { if (_parent == null) return new Thickness(0); if (_parent.MarkerBorderThickness == null) { if (this.Parent.RenderAs == RenderAs.Point && this.MarkerType == MarkerTypes.Cross) return new Thickness(1); else if (this.Parent.RenderAs == RenderAs.Bubble || (this.Parent.RenderAs == RenderAs.Point && this.MarkerType != MarkerTypes.Cross)) return new Thickness(0); else return new Nullable(new Thickness((Double)MarkerSize / 6)); } else return _parent.MarkerBorderThickness; } else return (Nullable)GetValue(MarkerBorderThicknessProperty); } set { SetValue(MarkerBorderThicknessProperty, value); } } /// /// Get or set the MarkerBorderColor property /// public Brush MarkerBorderColor { get { if (GetValue(MarkerBorderColorProperty) != null) { return (Brush)GetValue(MarkerBorderColorProperty); } else { if (_parent == null) return null; if (_parent.MarkerBorderColor != null) return (_parent.MarkerBorderColor); else return (_internalColor == null) ? _parent._internalColor : _internalColor; } } set { SetValue(MarkerBorderColorProperty, value); } } /// /// Get or set the MarkerSize property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableDoubleConverter))] #endif public Nullable MarkerSize { get { if ((Nullable)GetValue(MarkerSizeProperty) == null && _parent != null) return _parent.MarkerSize; else return (Nullable)GetValue(MarkerSizeProperty); } set { SetValue(MarkerSizeProperty, value); } } /// /// Get or set the MarkerColor property /// public Brush MarkerColor { get { if (GetValue(MarkerColorProperty) == null && _parent != null) { if (_parent.MarkerColor == null) return new SolidColorBrush(Colors.White); else return _parent.MarkerColor; } else return (Brush)GetValue(MarkerColorProperty); } set { SetValue(MarkerColorProperty, value); } } /// /// Get or set the MarkerScale property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableDoubleConverter))] #endif public Nullable MarkerScale { get { if ((Nullable)GetValue(MarkerScaleProperty) == null && _parent != null) return _parent.MarkerScale; else return (Nullable)GetValue(MarkerScaleProperty); } set { SetValue(MarkerScaleProperty, value); } } #endregion Marker Properties /// /// Get or set the ToolTipText for the DataPoint /// public override String ToolTipText { get { if ((Chart != null && !String.IsNullOrEmpty((Chart as Chart).ToolTipText))) return null; if ((String)GetValue(ToolTipTextProperty) == String.Empty && _parent != null) return _parent.ToolTipText; else return (String)GetValue(ToolTipTextProperty); } set { SetValue(ToolTipTextProperty, value); } } /// /// Get or set the ShowInLegend property /// [System.ComponentModel.TypeConverter(typeof(NullableBoolConverter))] public Nullable ShowInLegend { get { if ((Nullable)GetValue(ShowInLegendProperty) == null && _parent != null) { return _parent.ShowInLegend; } else { return (Nullable)GetValue(ShowInLegendProperty); } } set { SetValue(ShowInLegendProperty, value); } } /// /// Get or set the LegendText /// public String LegendText { get { if (String.IsNullOrEmpty((String)GetValue(LegendTextProperty)) && _parent != null) { if (String.IsNullOrEmpty(_parent.LegendText)) if (this.Parent.RenderAs == RenderAs.Pie || this.Parent.RenderAs == RenderAs.Doughnut || this.Parent.RenderAs == RenderAs.SectionFunnel || this.Parent.RenderAs == RenderAs.StreamLineFunnel) { if (Parent.InternalXValueType != ChartValueTypes.Numeric) return this.TextParser("#XValue"); else return this.TextParser("#AxisXLabel"); } else { if (_isAutoName) { String[] s = this.Name.Split('_'); return s[0]; } else return this.Name; } else return _parent.LegendText; } else { return (String)GetValue(LegendTextProperty); } } set { SetValue(LegendTextProperty, value); } } /// /// Get or set the BorderThickness property /// public new Thickness BorderThickness { get { Thickness retVal = (Thickness)GetValue(BorderThicknessProperty); if (retVal == new Thickness(0, 0, 0, 0)) retVal = (_parent == null) ? retVal : _parent.InternalBorderThickness; return retVal; } set { #if SL if (BorderThickness != value) { InternalBorderThickness = value; SetValue(BorderThicknessProperty, value); FirePropertyChanged("BorderThickness"); } #else SetValue(BorderThicknessProperty, value); #endif } } /// /// Get or set the BorderColor property /// public Brush BorderColor { get { if (GetValue(BorderColorProperty) == null && _parent != null) { return _parent.BorderColor; } else { return (Brush)GetValue(BorderColorProperty); } } set { SetValue(BorderColorProperty, value); } } /// /// Get or set the BorderStyle property /// #if SL [System.ComponentModel.TypeConverter(typeof(Converters.NullableBorderStylesConverter))] #endif public Nullable BorderStyle { get { if ((Nullable)GetValue(BorderStyleProperty) == null && _parent != null) { return _parent.BorderStyle; } else { return (Nullable)GetValue(BorderStyleProperty); } } set { SetValue(BorderStyleProperty, value); } } /// /// Get or set the RadiusX property /// #if WPF [System.ComponentModel.TypeConverter(typeof(System.Windows.CornerRadiusConverter))] #else [System.ComponentModel.TypeConverter(typeof(Converters.CornerRadiusConverter))] #endif public Nullable RadiusX { get { if ((Nullable)GetValue(RadiusXProperty) == null && _parent != null) return _parent.RadiusX; else return (Nullable)GetValue(RadiusXProperty); } set { SetValue(RadiusXProperty, value); } } /// /// Get or set the RadiusY property /// #if WPF [System.ComponentModel.TypeConverter(typeof(System.Windows.CornerRadiusConverter))] #else [System.ComponentModel.TypeConverter(typeof(Converters.CornerRadiusConverter))] #endif public Nullable RadiusY { get { if ((Nullable)GetValue(RadiusYProperty) == null && _parent != null) return _parent.RadiusY; else return (Nullable)GetValue(RadiusYProperty); } set { SetValue(RadiusYProperty, value); } } /// /// Parent of InternalDataPoints /// public new DataSeries Parent { get { return _parent; } internal set { System.Diagnostics.Debug.Assert(typeof(DataSeries).Equals(value.GetType()), "Unknown Parent", "DataPoint should have DataSeries as Parent"); _parent = value; } } #endregion #region Public Events #endregion #region Protected Methods /// /// UpdateVisual is used for partial rendering /// /// Name of the property /// Value of the property internal override void UpdateVisual(String propertyName, object value) { switch (propertyName) { case "Color": #region Color value = Color; if (Faces != null && Faces.Parts != null) { switch (Parent.RenderAs) { case RenderAs.Column: case RenderAs.Bar: case RenderAs.StackedBar: case RenderAs.StackedBar100: case RenderAs.StackedColumn: case RenderAs.StackedColumn100: if (!(Parent.Chart as Chart).View3D) { if (Faces.Parts[0] != null) (Faces.Parts[0] as Path).Fill = (((Boolean)Parent.LightingEnabled) ? Graphics.GetLightingEnabledBrush((Brush)value, "Linear", new Double[] { 0.745, 0.99 }) : (Brush)value); if (Faces.Parts[1] != null) (Faces.Parts[1] as Polygon).Fill = Graphics.GetBevelTopBrush((Brush)value); if (Faces.Parts[2] != null) (Faces.Parts[2] as Polygon).Fill = Graphics.GetBevelSideBrush(((Boolean)Parent.LightingEnabled ? -70 : 0), (Brush)value); if (Faces.Parts[3] != null) (Faces.Parts[3] as Polygon).Fill = Graphics.GetBevelSideBrush(((Boolean)Parent.LightingEnabled ? -110 : 180), (Brush)value); if (Faces.Parts[4] != null) (Faces.Parts[4] as Polygon).Fill = null; if (Faces.Parts[5] != null) (Faces.Parts[5] as Shape).Fill = Graphics.GetLeftGradianceBrush(63); if (Faces.Parts[6] != null) (Faces.Parts[6] as Shape).Fill = ((Parent.Chart as Chart).PlotDetails.ChartOrientation == ChartOrientationType.Vertical) ? Graphics.GetRightGradianceBrush(63) : Graphics.GetLeftGradianceBrush(63); } else { if (Faces.Parts[0] != null) (Faces.Parts[0] as Shape).Fill = (Boolean)Parent.LightingEnabled ? Graphics.GetFrontFaceBrush((Brush)value) : (Brush)value; // Front brush if (Faces.Parts[1] != null) (Faces.Parts[1] as Shape).Fill = (Boolean)Parent.LightingEnabled ? Graphics.GetTopFaceBrush((Brush)value) : (Brush)value; // Top brush if (Faces.Parts[2] != null) (Faces.Parts[2] as Shape).Fill = (Boolean)Parent.LightingEnabled ? Graphics.GetRightFaceBrush((Brush)value) : (Brush)value; // Right } break; case RenderAs.Bubble: if (Faces.Parts[0] != null) (Faces.Parts[0] as Shape).Fill = ((Parent.Chart as Chart).View3D ? Graphics.GetLightingEnabledBrush3D((Brush)value) : ((Boolean)LightingEnabled ? Graphics.GetLightingEnabledBrush((Brush)value, "Linear", new Double[] { 0.99, 0.745 }) : (Brush)value)); break; case RenderAs.Pie: case RenderAs.Doughnut: SectorChartShapeParams pieParams = (SectorChartShapeParams)this.VisualParams; pieParams.Background = (Brush)value; if (!(Parent.Chart as Chart).View3D) { if (Faces.Parts[0] != null) (Faces.Parts[0] as Shape).Fill = (Boolean)Parent.LightingEnabled ? Graphics.GetLightingEnabledBrush((Brush)value, "Radial", null) : (Brush)value; if (Faces.Parts[1] != null) (Faces.Parts[1] as Shape).Fill = (pieParams.StartAngle > Math.PI * 0.5 && pieParams.StartAngle <= Math.PI * 1.5) ? PieChart.GetDarkerBevelBrush(pieParams.Background, pieParams.StartAngle * 180 / Math.PI + 135) : PieChart.GetLighterBevelBrush(pieParams.Background, -pieParams.StartAngle * 180 / Math.PI); if (Faces.Parts[2] != null) (Faces.Parts[2] as Shape).Fill = (pieParams.StopAngle > Math.PI * 0.5 && pieParams.StopAngle <= Math.PI * 1.5) ? PieChart.GetLighterBevelBrush(pieParams.Background, pieParams.StopAngle * 180 / Math.PI + 135) : PieChart.GetDarkerBevelBrush(pieParams.Background, -pieParams.StopAngle * 180 / Math.PI); if (Faces.Parts[3] != null) (Faces.Parts[3] as Shape).Fill = (pieParams.MeanAngle > 0 && pieParams.MeanAngle < Math.PI) ? PieChart.GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(-0.745, -0.85), Graphics.GenerateDoubleCollection(0, 1)) : (Faces.Parts[3] as Shape).Fill = PieChart.GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(0.745, -0.99), Graphics.GenerateDoubleCollection(0, 1)); if (Parent.RenderAs == RenderAs.Doughnut && Faces.Parts[4] != null) (Faces.Parts[4] as Shape).Fill = (pieParams.MeanAngle > 0 && pieParams.MeanAngle < Math.PI) ? PieChart.GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(-0.745, -0.85), Graphics.GenerateDoubleCollection(0, 1)) : (Faces.Parts[4] as Shape).Fill = PieChart.GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(0.745, -0.99), Graphics.GenerateDoubleCollection(0, 1)); } else { foreach (FrameworkElement fe in Faces.Parts) if (fe != null) (fe as Shape).Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", null) : pieParams.Background; } break; case RenderAs.SectionFunnel: case RenderAs.StreamLineFunnel: FunnelSliceParms funnelSliceParms = (FunnelSliceParms)this.VisualParams; foreach (Shape path in Faces.Parts) { FunnelChart.ReCalculateAndApplyTheNewBrush(path, (Brush)value, (Boolean)LightingEnabled, (Parent.Chart as Chart).View3D, funnelSliceParms); } break; case RenderAs.CandleStick: foreach (Shape path in Faces.Parts) { CandleStick.ReCalculateAndApplyTheNewBrush(this, path, (Brush)value, (Boolean)LightingEnabled, (Parent.Chart as Chart).View3D); } break; case RenderAs.Stock: foreach (Shape path in Faces.Parts) { StockChart.ReCalculateAndApplyTheNewBrush(path, (Brush)value, (Boolean)LightingEnabled); } break; } } UpdateMarkerAndLegend(value); #endregion break; default: FirePropertyChanged(propertyName); break; } } #endregion #region Internal Properties #if SL /// /// Identifies the Visifire.Charts.Axis.Opacity dependency property. /// /// /// The identifier for the Visifire.Charts.DataSeries.Opacity dependency property. /// private static readonly DependencyProperty InternalOpacityProperty = DependencyProperty.Register ("InternalOpacity", typeof(Double), typeof(DataPoint), new PropertyMetadata(1.0, OnOpacityPropertyChanged)); /// /// Identifies the Visifire.Charts.Title.BorderThickness dependency property. /// /// /// The identifier for the Visifire.Charts.DataSeries.BorderThickness dependency property. /// private static readonly DependencyProperty InternalBorderThicknessProperty = DependencyProperty.Register ("InternalBorderThickness", typeof(Thickness), typeof(DataPoint), new PropertyMetadata(OnBorderThicknessPropertyChanged)); #endif /// /// Get or set the BorderThickness of title /// internal Thickness InternalBorderThickness { get { Thickness retVal = (Thickness)((_borderThickness == null) ? GetValue(BorderThicknessProperty) : _borderThickness); if (retVal == new Thickness(0, 0, 0, 0)) retVal = (_parent == null) ? retVal : _parent.InternalBorderThickness; return retVal; } set { _borderThickness = value; } } /// /// Get or set the Opacity property /// internal Double InternalOpacity { get { return (Double)(Double.IsNaN(_internalOpacity) ? GetValue(OpacityProperty) : _internalOpacity); } set { _internalOpacity = value; } } internal Boolean IsLabelStyleSet { get; set; } /// /// InternalXValue used for internally generated XValue of type double /// internal Double InternalXValue { get; set; } /// /// InternalXValue used for internally generated XValue of type DateTime /// internal DateTime InternalXValueAsDateTime { get; set; } /// /// Get or set Marker which appears in Legend /// internal Marker LegendMarker { get; set; } /// /// Get or set geometric faces of DataPoint /// internal Faces Faces { get; set; } /// /// Get or set label visual of the DataPoint /// internal FrameworkElement LabelVisual { get; set; } /// /// Get or set Marker associated with DataPoint /// internal Marker Marker { get; set; } /// /// Get or set Line for label /// (For Pie / Doughnut) /// internal Path LabelLine; /// /// Get or set Storyboard for explode animation /// internal Storyboard ExplodeAnimation { get; set; } /// /// Get or set Storyboard for unexplode animation /// internal Storyboard UnExplodeAnimation { get; set; } /// /// Get or set current visual parameters /// internal object VisualParams { get; set; } #endregion #region Private Delegates #endregion #region Private Properties [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] private new Brush BorderBrush { get; set; } #endregion #region Private Methods /// /// SelectedProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; ApplySelectionChanged(dataPoint, (Boolean)e.NewValue); } private static void ApplySelectionChanged(DataPoint dataPoint, Boolean selectedValue) { if (dataPoint.Parent == null) return; Boolean selected = selectedValue & dataPoint.Parent.SelectionEnabled; if (selected) { dataPoint.Select(true); if (dataPoint.Parent.SelectionMode == SelectionModes.Single || dataPoint.Parent.RenderAs == RenderAs.SectionFunnel || dataPoint.Parent.RenderAs == RenderAs.StreamLineFunnel) dataPoint.DeSelectOthers(); } else dataPoint.DeSelect(dataPoint, true, true); } /// /// HrefTargetProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnHrefTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("HrefTarget"); } /// /// HrefProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnHrefChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("Href"); } /// /// OpacityProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnOpacityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.InternalOpacity = (Double)e.NewValue; dataPoint.FirePropertyChanged("Opacity"); } /// /// YValueProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnYValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("YValue"); } private static void OnYValuesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("YValues"); } /// /// XValueProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnXValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; // Double / Int32 value entered in Managed Code if (e.NewValue.GetType().Equals(typeof(Double)) || e.NewValue.GetType().Equals(typeof(Int32))) { dataPoint.InternalXValue = Convert.ToDouble(e.NewValue); dataPoint.XValueType = ChartValueTypes.Numeric; } // DateTime value entered in Managed Code else if ((e.NewValue.GetType().Equals(typeof(DateTime)))) { dataPoint.InternalXValueAsDateTime = (DateTime)e.NewValue; dataPoint.XValueType = ChartValueTypes.DateTime; } // Double / Int32 / DateTime entered in XAML else if ((e.NewValue.GetType().Equals(typeof(String)))) { DateTime dateTimeresult; Double doubleResult; if (String.IsNullOrEmpty(e.NewValue.ToString())) { dataPoint.InternalXValue = Double.NaN; dataPoint.XValueType = ChartValueTypes.Numeric; } // Double entered in XAML else if (Double.TryParse((string)e.NewValue, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out doubleResult)) { dataPoint.InternalXValue = doubleResult; dataPoint.XValueType = ChartValueTypes.Numeric; } // DateTime entered in XAML else if (DateTime.TryParse((string)e.NewValue, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTimeresult)) { dataPoint.InternalXValueAsDateTime = dateTimeresult; dataPoint.XValueType = ChartValueTypes.DateTime; } else { System.Diagnostics.Debug.WriteLine("Invalid Input for XValue"); throw new Exception("Invalid Input for XValue"); } } else { System.Diagnostics.Debug.WriteLine("Invalid Input for XValue"); throw new Exception("Invalid Input for XValue"); } dataPoint.FirePropertyChanged("XValue"); } /// /// ZValueProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnZValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("ZValue"); } /// /// AxisXLabelProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnAxisXLabelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("AxisXLabel"); } /// /// ColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.UpdateVisual("Color", e.NewValue); } /// /// EnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("Enabled"); } /// /// ExplodedProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnExplodedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; DataSeries dataSeries = dataPoint.Parent; if (dataSeries == null) return; Chart chart = dataSeries.Chart as Chart; if (dataPoint.IsNotificationEnable && chart != null && chart.ChartArea != null && chart.ChartArea.PlotDetails != null && chart.ChartArea.PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) { if (chart.ChartArea._isAnimationFired && (dataPoint.Parent.RenderAs == RenderAs.SectionFunnel || dataPoint.Parent.RenderAs == RenderAs.StreamLineFunnel)) { if (dataPoint.Parent.Exploded == false) dataPoint.ExplodeOrUnexplodeAnimation(); } else { if (chart.AnimationEnabled && !chart.ChartArea._isAnimationFired) return; dataPoint.ExplodeOrUnexplodeAnimation(); } } } /// /// LightingEnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLightingEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LightingEnabled"); } /// /// ShadowEnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnShadowEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("ShadowEnabled"); } /// /// LabelEnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelEnabled"); } /// /// LabelTextProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelText"); } /// /// LabelFontFamilyProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelFontFamilyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelFontFamily"); } /// /// LabelFontSizeProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelFontSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelFontSize"); } /// /// LabelFontColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelFontColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelFontColor"); } /// /// LabelFontWeightProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelFontWeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelFontWeight"); } /// /// LabelFontStyleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelFontStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelFontStyle"); } /// /// LabelBackgroundProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelBackgroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelBackground"); } /// /// LabelStyleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelStyle"); } /// /// LabelLineEnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelLineEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelLineEnabled"); } /// /// LabelLineColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelLineColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelLineColor"); } /// /// LabelLineThicknessProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelLineThicknessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelLineThickness"); } /// /// LabelLineStyleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelLineStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelLineStyle"); } /// /// LabelAngleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLabelAnglePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LabelAngle"); } /// /// MarkerEnabledProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("MarkerEnabled"); } /// /// MarkerTypeProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("MarkerType"); } /// /// MarkerBorderThicknessProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerBorderThicknessPropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.UpdateMarker(); } /// /// MarkerBorderColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerBorderColorPropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.UpdateMarker(); } /// /// MarkerSizeProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerSizePropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("MarkerSize"); } /// /// MarkerColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerColorPropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.UpdateMarker(); } /// /// MarkerScaleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnMarkerScalePropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("MarkerScale"); } /// /// ShowInLegendProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnShowInLegendPropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("ShowInLegend"); } /// /// LegendTextProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnLegendTextPropertychanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("LegendText"); } /// /// BorderThicknessProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnBorderThicknessPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.InternalBorderThickness = (Thickness)e.NewValue; dataPoint.FirePropertyChanged("BorderThickness"); } /// /// BorderColorProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnBorderColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("BorderColor"); } /// /// BorderStyleProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnBorderStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("BorderStyle"); } /// /// RadiusXProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnRadiusXPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("RadiusX"); } /// /// RadiusYProperty changed call back function /// /// DependencyObject /// DependencyPropertyChangedEventArgs private static void OnRadiusYPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { DataPoint dataPoint = d as DataPoint; dataPoint.FirePropertyChanged("RadiusY"); } internal void DeSelectOthers() { if (Parent != null) { foreach (DataPoint dp in Parent.DataPoints) { if (dp != this) dp.DeSelect(dp, false, true); } } } /// /// Select a DataPoint visually /// /// Whether to allow any property change internal void Select(Boolean allowPropertyChange) { if (Faces != null) { if (allowPropertyChange) UpdateExplodedPropertyForSelection(true, true); foreach (Shape shape in Faces.BorderElements) { BorderStyles borderStyle = BorderStyles.Dashed; Double borderThickness = 1.5; if (Parent != null) { if ((Parent.RenderAs == RenderAs.Pie || Parent.RenderAs == RenderAs.Doughnut) && (Chart as Chart).View3D) { borderStyle = BorderStyles.Dotted; } if ((Parent.RenderAs == RenderAs.Column || Parent.RenderAs == RenderAs.Bar) && !(Chart as Chart).View3D) { borderThickness = 1.5; } } Brush borderColor; if (Parent.RenderAs == RenderAs.Stock) { borderColor = StockChart.ReCalculateAndApplyTheNewBrush(shape, Color, (Boolean)LightingEnabled); } else borderColor = Visifire.Charts.Chart.CalculateDataPointLabelFontColor(Chart as Chart, this, null, LabelStyles.OutSide); InteractivityHelper.ApplyBorderEffect(shape, borderStyle, borderThickness, borderColor); } } if (Parent != null && Marker != null && (Parent.RenderAs == RenderAs.Area || Parent.RenderAs == RenderAs.Line || Parent.RenderAs == RenderAs.StackedArea || Parent.RenderAs == RenderAs.StackedArea100)) { if (allowPropertyChange) UpdateExplodedPropertyForSelection(true, true); if (InteractivityHelper.SELECTED_MARKER_BORDER_COLOR == null) InteractivityHelper.SELECTED_MARKER_BORDER_COLOR = new SolidColorBrush(Colors.Red); if (InteractivityHelper.SELECTED_MARKER_FILL_COLOR == null) InteractivityHelper.SELECTED_MARKER_FILL_COLOR = new SolidColorBrush(Colors.Orange); InteractivityHelper.ApplyBorderEffect(Marker.MarkerShape, BorderStyles.Solid, InteractivityHelper.SELECTED_MARKER_BORDER_COLOR, 1.2, 2.4, InteractivityHelper.SELECTED_MARKER_FILL_COLOR); Marker.MarkerShape.Margin = new Thickness(-1.2, -1.2, 0, 0); if (Parent.RenderAs == RenderAs.Line) LineChart.SelectMovingMarker(this); } } /// /// Deselect a DataPoint visually /// /// DataPoint /// Whether the action taken by the selected or deselected DataPoint to update its own Exploded property /// Whether to allow any property change internal void DeSelect(DataPoint dataPoint, Boolean selfDeSelect, Boolean allowPropertyChange) { if (Faces != null) { if (allowPropertyChange) UpdateExplodedPropertyForSelection(false, selfDeSelect); foreach (Shape shape in Faces.BorderElements) { if (dataPoint.Parent != null && (dataPoint.Parent.RenderAs == RenderAs.Pie || dataPoint.Parent.RenderAs == RenderAs.Doughnut)) InteractivityHelper.RemoveBorderEffect(shape, (BorderStyles)dataPoint.BorderStyle, ((Thickness)InternalBorderThickness).Left, BorderColor); else { Brush borderColor; if (Parent.RenderAs == RenderAs.Stock) borderColor = StockChart.ReCalculateAndApplyTheNewBrush(shape, dataPoint.Color, (Boolean)dataPoint.LightingEnabled); else borderColor = BorderColor; InteractivityHelper.RemoveBorderEffect(shape, (BorderStyles)dataPoint.BorderStyle, ((Thickness)InternalBorderThickness).Left, borderColor); } if (allowPropertyChange) { IsNotificationEnable = false; Selected = false; IsNotificationEnable = true; } } } if (Parent != null && Marker != null && (Parent.RenderAs == RenderAs.Area || Parent.RenderAs == RenderAs.Line || Parent.RenderAs == RenderAs.StackedArea || Parent.RenderAs == RenderAs.StackedArea100)) { if (allowPropertyChange) UpdateExplodedPropertyForSelection(false, selfDeSelect); InteractivityHelper.RemoveBorderEffect(Marker.MarkerShape, (BorderStyles)dataPoint.BorderStyle, Marker.BorderThickness, Marker.BorderColor, Marker.MarkerFillColor, Marker.MarkerSize.Width * Marker.ScaleFactor, Marker.MarkerSize.Height * Marker.ScaleFactor); Marker.MarkerShape.Margin = new Thickness(0, 0, 0, 0); if (allowPropertyChange) { IsNotificationEnable = false; Selected = false; IsNotificationEnable = true; } } } /// /// Update exploded property for selection /// /// Exploded /// Whether the action taken by the selected or deselected DataPoint to update its own Exploded property private void UpdateExplodedPropertyForSelection(Boolean exploded, Boolean selfAction) { // if (Parent != null && Parent.Chart != null && (Parent.Chart as Chart).ChartArea != null && (Parent.Chart as Chart).ChartArea.PlotDetails.ChartOrientation == ChartOrientationType.NoAxis) { if (Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { if (Exploded != exploded) { // For self action we need to update Exploded property if (selfAction) Exploded = exploded; else // If it is not a self action we need to update Exploded property with out firing any event { IsNotificationEnable = false; Exploded = exploded; IsNotificationEnable = true; } } } else { if (Exploded != exploded) { Exploded = exploded; } } } } /// /// Returns cursor type of the DataPoint /// /// private Cursor GetCursor() { if (this.Cursor == null) { if (_parent != null && _parent.Cursor == null) return Cursors.Arrow; else return _parent.Cursor; } else { return this.Cursor; } } /// /// MouseLeftButtonUp event handler for handling interactive animation /// /// FrameworkElement /// MouseButtonEventArgs private void Visual_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { InteractiveAnimation(false); } /// /// Event handler attached with Completed event of the storyboard for explode animation /// /// FrameworkElement /// EventArgs private void ExplodeAnimation_Completed(object sender, EventArgs e) { _interactiveExplodeState = true; _interativityAnimationState = false; Chart._rootElement.IsHitTestVisible = true; } /// /// Event handler attached with Completed event of the storyboard for unexplode animation /// /// FrameworkElement /// EventArgs private void UnExplodeAnimation_Completed(object sender, EventArgs e) { _interactiveExplodeState = false; _interativityAnimationState = false; } /// /// Returns label text for AxisX /// /// String private String GetAxisXLabelString() { String labelString = ""; if (Parent.PlotGroup != null && Parent.PlotGroup.AxisX != null && Parent.PlotGroup.AxisX.AxisLabels != null) { if (Parent.PlotGroup.AxisX.AxisLabels.AxisLabelContentDictionary != null && Parent.PlotGroup.AxisX.AxisLabels.AxisLabelContentDictionary.ContainsKey(InternalXValue)) { labelString = Parent.PlotGroup.AxisX.AxisLabels.AxisLabelContentDictionary[InternalXValue]; } else { labelString = Parent.PlotGroup.AxisX.GetFormattedString(InternalXValue); } } else labelString = this.AxisXLabel; return labelString; } /// /// Explode or unexplode animation for Pie and Doughnut /// internal void ExplodeOrUnexplodeAnimation() { //if (Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) //{ // Int32 i = 0; // if (Parent.Exploded) // { // foreach (DataPoint dp in Parent.DataPoints) // { // dp.Faces.Visual.SetValue(Canvas.TopProperty, (VisualParams as FunnelSliceParms).ExplodedPoints[i++].Y); // } // } // else // { // if ((Boolean)Exploded) // { // foreach (DataPoint dp in Parent.DataPoints) // { // if (dp != this) // { // dp.IsNotificationEnable = false; // dp.Exploded = false; // dp.IsNotificationEnable = true; // } // if (Parent.RenderAs == RenderAs.SectionFunnel) // dp.Faces.Visual.SetValue(Canvas.TopProperty, (VisualParams as FunnelSliceParms).ExplodedPoints[i++].Y); // else if (VisualParams != null // && dp.Chart != null && (dp.Chart as Chart).PlotDetails != null // && (dp.Chart as Chart).PlotDetails.PlotGroups != null // && (dp.Chart as Chart).PlotDetails.PlotGroups.Count > 0 // && dp.YValue != (dp.Chart as Chart).PlotDetails.PlotGroups[0].MaximumY) // { // dp.Faces.Visual.SetValue(Canvas.TopProperty, (VisualParams as FunnelSliceParms).ExplodedPoints[i++].Y); // } // } // } // else // { // foreach (DataPoint dp in Parent.DataPoints) // { // if (dp != this) // { // dp.IsNotificationEnable = false; // dp.Exploded = false; // dp.IsNotificationEnable = true; // } // if (Parent.RenderAs == RenderAs.SectionFunnel) // dp.Faces.Visual.SetValue(Canvas.TopProperty, (dp.VisualParams as FunnelSliceParms).Top); // else if (VisualParams != null // && dp.Chart != null && (dp.Chart as Chart).PlotDetails != null // && (dp.Chart as Chart).PlotDetails.PlotGroups != null // && (dp.Chart as Chart).PlotDetails.PlotGroups.Count > 0 // && dp.YValue != (dp.Chart as Chart).PlotDetails.PlotGroups[0].MaximumY) // { // // Restore all slice back to their orginal position // dp.Faces.Visual.SetValue(Canvas.TopProperty, (dp.VisualParams as FunnelSliceParms).Top); // } // } // } // } //} //else { if ((Boolean)Exploded) { if (this.UnExplodeAnimation != null) this.UnExplodeAnimation.Stop(); if (this.ExplodeAnimation != null) { try { _isAlreadyExploded = true; #if WPF this.ExplodeAnimation.Begin(Chart._rootElement, true); #else this.ExplodeAnimation.Begin(); #endif } catch { _isAlreadyExploded = false; } } } else if (_isAlreadyExploded == true) { UnExplodeFunnelSlices(); if (this.ExplodeAnimation != null) this.ExplodeAnimation.Stop(); if (this.UnExplodeAnimation != null) { _isAlreadyExploded = false; #if WPF this.UnExplodeAnimation.Begin(Chart._rootElement, true); #else this.UnExplodeAnimation.Begin(); #endif } } } } private void UnExplodeFunnelSlices() { if (Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { if (this.UnExplodeAnimation != null) { this.UnExplodeAnimation.Completed -= ExplodeAnimation_Completed; this.UnExplodeAnimation = null; } this.UnExplodeAnimation = new Storyboard(); foreach (FunnelSliceParms funnleSlice in (Parent.VisualParams as FunnelSliceParms[])) { this.UnExplodeAnimation = FunnelChart.CreateUnExplodingAnimation(Parent, this, this.UnExplodeAnimation, funnleSlice.DataPoint.Faces.Visual as Panel, funnleSlice.Top); } this.UnExplodeAnimation.Completed += ExplodeAnimation_Completed; } } /// /// Calculate percentage value among InternalDataPoints /// /// Double private Double Percentage() { Double percentage = 0; if (Parent.RenderAs == RenderAs.Pie || Parent.RenderAs == RenderAs.Doughnut || Parent.RenderAs == RenderAs.SectionFunnel) { if ((Parent.Chart as Chart).PlotDetails != null) { Double sum = (Parent.Chart as Chart).PlotDetails.GetAbsoluteSumOfDataPoints(Parent.InternalDataPoints.ToList()); if (sum > 0) percentage = ((InternalYValue / sum) * 100); else percentage = 0; } } else if (Parent.RenderAs == RenderAs.StreamLineFunnel) { percentage = ((InternalYValue / Parent.PlotGroup.MaximumY) * 100); } else if (Parent.RenderAs == RenderAs.StackedArea100 || Parent.RenderAs == RenderAs.StackedBar100 || Parent.RenderAs == RenderAs.StackedColumn100) { percentage = InternalYValue / Parent.PlotGroup.XWiseStackedDataList[InternalXValue].AbsoluteYValueSum * 100;// _stackSum[XValue].Y Contains Absolute sum } return percentage; } /// /// Update marker and legend for dataPoint /// /// Color value private void UpdateMarkerAndLegend(object colorValue) { // Double markerThickness; if (Marker != null && Marker.Visual != null && (Boolean)MarkerEnabled) { if (Parent.RenderAs == RenderAs.Point) { Marker.MarkerFillColor = (Brush)colorValue; if (Marker.MarkerType != MarkerTypes.Cross) { if (BorderColor != null) Marker.BorderColor = BorderColor; } else Marker.BorderColor = (Brush)colorValue; // Marker.UpdateMarker(); } else Marker.BorderColor = (Brush)colorValue; //markerThickness = Marker.MarkerShape.StrokeThickness; if (!Selected) Marker.UpdateMarker(); } if (LegendMarker != null && LegendMarker.Visual != null) { LegendMarker.BorderColor = (Brush)colorValue; //LegendMarker.MarkerFillColor = (Brush)colorValue; if (Parent.RenderAs == RenderAs.Line || Parent.RenderAs == RenderAs.CandleStick || Parent.RenderAs == RenderAs.Stock) { if ((LegendMarker.Visual as Grid).Parent != null && (((LegendMarker.Visual as Grid).Parent as Canvas).Children[0] as Line) != null) (((LegendMarker.Visual as Grid).Parent as Canvas).Children[0] as Line).Stroke = (Brush)colorValue; } else LegendMarker.MarkerFillColor = (Brush)colorValue; LegendMarker.UpdateMarker(); } } #endregion #region Internal Methods /// /// Start interactive animation /// internal void InteractiveAnimation(Boolean isFirstTimeAnimation) { // If interactivity animation is not running already and the slice is not exploded // then explode the slice if (Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { if (!Parent.Exploded) { if (isFirstTimeAnimation) { if (Exploded == true) ExplodeOrUnexplodeAnimation(); } else { if (!Parent.SelectionEnabled) { foreach (DataPoint dp in Parent.InternalDataPoints) { if (dp != this) { dp.IsNotificationEnable = false; dp.Exploded = false; dp._isAlreadyExploded = false; dp.IsNotificationEnable = true; } } Exploded = !Exploded; } } } } else { if (!_interativityAnimationState) { if (false == _interactiveExplodeState) { _interativityAnimationState = true; System.Diagnostics.Debug.WriteLine("Intractivity-- Exploded"); Exploded = true; if (this.ExplodeAnimation != null) { #if WPF this.ExplodeAnimation.Begin(Chart._rootElement, true); #else this.ExplodeAnimation.Begin(); #endif _isAlreadyExploded = true; } } if (true == _interactiveExplodeState) { _interativityAnimationState = true; Exploded = false; UnExplodeFunnelSlices(); System.Diagnostics.Debug.WriteLine("Intractivity-- UnExploded"); if (this.UnExplodeAnimation != null) { #if WPF this.UnExplodeAnimation.Begin(Chart._rootElement, true); #else this.UnExplodeAnimation.Begin(); #endif } } } } } /// /// Attach events to each and every individual face of Faces /// /// Object where events to be attached internal void AttachEvent2DataPointVisualFaces(ObservableObject Object) { if (Parent.RenderAs == RenderAs.Pie || Parent.RenderAs == RenderAs.Doughnut || Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { if (Faces != null) { if ((Parent.Chart as Chart).View3D) { foreach (FrameworkElement element in Faces.VisualComponents) { AttachEvents2Visual(Object, this, element); if((Chart as Chart).ChartArea != null && (Chart as Chart).ChartArea._isDefaultInteractivityAllowed) { element.MouseLeftButtonUp -= new MouseButtonEventHandler(Visual_MouseLeftButtonUp); element.MouseLeftButtonUp += new MouseButtonEventHandler(Visual_MouseLeftButtonUp); } } } else { AttachEvents2Visual(Object, this, Faces.Visual); if ((Chart as Chart).ChartArea != null && (Chart as Chart).ChartArea._isDefaultInteractivityAllowed) { Faces.Visual.MouseLeftButtonUp -= new MouseButtonEventHandler(Visual_MouseLeftButtonUp); Faces.Visual.MouseLeftButtonUp += new MouseButtonEventHandler(Visual_MouseLeftButtonUp); } } if (this.ExplodeAnimation != null) { this.ExplodeAnimation.Completed -= new EventHandler(ExplodeAnimation_Completed); this.ExplodeAnimation.Completed += new EventHandler(ExplodeAnimation_Completed); } if (this.UnExplodeAnimation != null) { this.UnExplodeAnimation.Completed -= new EventHandler(UnExplodeAnimation_Completed); this.UnExplodeAnimation.Completed += new EventHandler(UnExplodeAnimation_Completed); } } } else if (Parent.RenderAs == RenderAs.Area || Parent.RenderAs == RenderAs.StackedArea || Parent.RenderAs == RenderAs.StackedArea100 || Parent.RenderAs == RenderAs.Line) { if (Parent.RenderAs != RenderAs.Line) { if (Parent.Faces != null) { if (Object.GetType().Equals(typeof(DataPoint))) { foreach (FrameworkElement face in Parent.Faces.VisualComponents) AttachEvents2AreaVisual(Object, this, face); } } } if (Marker != null) AttachEvents2Visual(Object, this, Marker.Visual); } else if (Faces != null) { if (Parent.RenderAs == RenderAs.Point || Parent.RenderAs == RenderAs.Stock || Parent.RenderAs == RenderAs.CandleStick || Parent.RenderAs == RenderAs.SectionFunnel || Parent.RenderAs == RenderAs.StreamLineFunnel) { foreach (FrameworkElement face in Faces.VisualComponents) { AttachEvents2Visual(Object, this, face); } } else { AttachEvents2Visual(Object, this, Faces.Visual); if (Marker != null) AttachEvents2Visual(Object, this, Marker.Visual); } } } /// /// Set Href property for DataPoint visual faces /// internal void SetHref2DataPointVisualFaces() { if (Faces != null) if (Faces.VisualComponents.Count != 0) { foreach (FrameworkElement face in Faces.VisualComponents) { AttachHref(Chart, face, Href, (HrefTargets)HrefTarget); } } else AttachHref(Chart, Faces.Visual, Href, (HrefTargets)HrefTarget); if (this.Parent.Faces != null) if (this.Parent.Faces.VisualComponents.Count != 0) { foreach (FrameworkElement face in this.Parent.Faces.VisualComponents) { if (Parent.RenderAs != RenderAs.Area && Parent.RenderAs != RenderAs.StackedArea && Parent.RenderAs != RenderAs.StackedArea100) AttachHref(Chart, face, Href, (HrefTargets)HrefTarget); } } else AttachHref(Chart, this.Parent.Faces.Visual, Href, (HrefTargets)HrefTarget); if (this.Marker != null) { AttachHref(Chart, Marker.Visual, Href, (HrefTargets)HrefTarget); } } /// /// Set Cursor property for DataPoint visual faces /// internal void SetCursor2DataPointVisualFaces() { if (Faces != null) if (Faces.VisualComponents.Count != 0) { foreach (FrameworkElement face in Faces.VisualComponents) { face.Cursor = GetCursor(); } } else Faces.Visual.Cursor = GetCursor(); if (this.Parent.Faces != null) if (this.Parent.Faces.VisualComponents.Count != 0) { foreach (FrameworkElement face in this.Parent.Faces.VisualComponents) { face.Cursor = GetCursor(); } } else this.Parent.Faces.Visual.Cursor = GetCursor(); if (this.Marker != null) { Marker.Visual.Cursor = GetCursor(); } } /// /// Update marker associated with DataPoint /// internal void UpdateMarker() { if (Marker != null && Marker.Visual != null && (Boolean)MarkerEnabled) { Marker.BorderThickness = ((Thickness)(MarkerBorderThickness as Nullable)).Left; Marker.BorderColor = MarkerBorderColor; Marker.MarkerFillColor = MarkerColor; Marker.UpdateMarker(); } } #endregion #region Internal Events #endregion #region Data /// /// Parent of this DataPoint /// private DataSeries _parent; /// /// Whether the DataPoint is exploded (used for Pie / Doughnut) /// private Boolean _interactiveExplodeState = false; /// /// Whether the animation is going on for the datapoint /// private Boolean _interativityAnimationState = false; /// /// Internal color holds color from theme /// internal Brush _internalColor; /// /// Whether name for DataPoint is generated automatically /// internal Boolean _isAutoName = true; /// /// Distance from mouse pointer used for line chart only /// internal Double _distance; /// /// Whether the DataPoint is already Exploded /// private Boolean _isAlreadyExploded = false; /// /// Whether price is up for financial charts /// internal Boolean _isPriceUp; Nullable _borderThickness = null; Double _internalOpacity = Double.NaN; #if WPF /// /// Whether the default style is applied /// private static Boolean _defaultStyleKeyApplied; #endif #endregion } }