/// <summary>
        /// Creates the LegendItem Control if conditions are right.
        /// </summary>
        private void CreateLegendItemDataPoint()
        {
            DataPoint dataPoint = CreateDataPoint();

            if (null != PlotArea)
            {
                // Bounce into the visual tree to get default Style applied
                PlotArea.Children.Add(dataPoint);
                PlotArea.Children.Remove(dataPoint);
            }
            dataPoint.SetStyle(ActualDataPointStyle);
            LegendItem.Content = Title;
            // Start DataContext null to avoid Binding warnings in the output window
            LegendItem.DataContext = null;
            LegendItem.Loaded     += delegate
            {
                // Wait for Loaded to set the DataPoint
                LegendItem.DataContext = dataPoint;
            };
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a legend item from a data point.
        /// </summary>
        /// <param name="dataPoint">The data point to use to create the legend item.</param>
        /// <param name="index">The 1-based index of the Control.</param>
        /// <returns>The series host legend item.</returns>
        private LegendItem CreatePieLegendItem(DataPoint dataPoint, int index)
        {
            LegendItem legendItem = CreateLegendItem();

            // Set the Content of the LegendItem
            legendItem.Content = dataPoint.IndependentValue ?? index;
            // Create a representative DataPoint for access to styled properties
            DataPoint legendDataPoint = CreateDataPoint();

            legendDataPoint.DataContext = dataPoint.DataContext;
            if (null != PlotArea)
            {
                // Bounce into the visual tree to get default Style applied
                PlotArea.Children.Add(legendDataPoint);
                PlotArea.Children.Remove(legendDataPoint);
            }
            legendDataPoint.SetStyle(dataPoint.Style);
            legendItem.DataContext = legendDataPoint;
            return(legendItem);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a DataPoint for determining the line color.
 /// </summary>
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     if (null != PlotArea)
     {
         Grid      grid      = new Grid();
         DataPoint dataPoint = CreateDataPoint();
         dataPoint.Visibility = Visibility.Collapsed;
         dataPoint.Loaded    += delegate
         {
             dataPoint.SetStyle(ActualDataPointStyle);
             Background = dataPoint.Background;
             if (null != PlotArea)
             {
                 PlotArea.Children.Remove(grid);
             }
         };
         grid.Children.Add(dataPoint);
         PlotArea.Children.Add(grid);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a legend item for each data point.
        /// </summary>
        /// <param name="dataPoint">The data point added.</param>
        protected override void AddDataPoint(DataPoint dataPoint)
        {
            base.AddDataPoint(dataPoint);

            int index = ActiveDataPoints.IndexOf(dataPoint) + 1;

            // Grab a style enumerator if we don't have one already.
            if (_styleEnumerator == null)
            {
                _styleEnumerator = this.GetStylesWithTargetType(typeof(PieDataPoint), true);
            }

            if (_styleEnumerator.MoveNext())
            {
                Style style = _styleEnumerator.Current;
                dataPoint.SetStyle(style);
            }

            LegendItem legendItem = CreatePieLegendItem(dataPoint, index);

            _dataPointLegendItems[dataPoint] = legendItem;
            LegendItems.Add(legendItem);
            UpdateLegendItemIndexes();
        }
 /// <summary>
 /// Sets the style of the data point to the single style used for all
 /// data points.
 /// </summary>
 /// <param name="dataPoint">The data point to apply the style to.
 /// </param>
 /// <param name="dataContext">The object associated with the data point.
 /// </param>
 protected override void PrepareDataPoint(DataPoint dataPoint, object dataContext)
 {
     dataPoint.SetStyle(ActualDataPointStyle);
     base.PrepareDataPoint(dataPoint, dataContext);
 }
 /// <summary>
 /// Sets the style of the data point to the single style used for all
 /// data points.
 /// </summary>
 /// <param name="dataPoint">The data point to apply the style to.
 /// </param>
 /// <param name="dataContext">The object associated with the data point.
 /// </param>
 protected override void PrepareDataPoint(DataPoint dataPoint, object dataContext)
 {
     dataPoint.SetStyle(ActualDataPointStyle);
     base.PrepareDataPoint(dataPoint, dataContext);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a legend item for each data point.
        /// </summary>
        /// <param name="dataPoint">The data point added.</param>
        protected override void AddDataPoint(DataPoint dataPoint)
        {
            base.AddDataPoint(dataPoint);

            int index = ActiveDataPoints.IndexOf(dataPoint) + 1;

            // Grab a style enumerator if we don't have one already.
            if (_styleEnumerator == null)
            {
                _styleEnumerator = this.GetStylesWithTargetType(typeof(PieDataPoint), true);
            }

            if (_styleEnumerator.MoveNext())
            {
                Style style = _styleEnumerator.Current;
                dataPoint.SetStyle(style);
            }

            LegendItem legendItem = CreatePieLegendItem(dataPoint, index);
            _dataPointLegendItems[dataPoint] = legendItem;
            LegendItems.Add(legendItem);
            UpdateLegendItemIndexes();
        }