Exemplo n.º 1
0
        /// <summary>
        /// If at least one arc is small, all labels are displayed connected by a line. Otherwise, they're positioned
        /// in the arc midpoint.
        /// </summary>
        /// <returns>Return the top and left position of the label in the label area panel.</returns>
        private void PositionAuto()
        {
            Chart chart = TreeHelper.FindAncestor <Chart>(this);

            if (chart != null)
            {
                //PieChartLabelArea labelArea = chart.Template.FindName("LabelArea_PART", chart) as PieChartLabelArea;
                PieChartLabelArea labelArea = TreeHelper.FindDescendent(chart, "LabelArea_PART") as PieChartLabelArea;
                if (labelArea != null && labelArea.HasSmallArc)
                {
                    this.PositionConnected();
                }
                else
                {
                    this.PositionArcMidpoint();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the labels to each of its PieDataPoints.
        /// </summary>
        protected override void OnAfterUpdateDataPoints()
        {
            LabeledPieChart chart = this.SeriesHost as LabeledPieChart;

            if (chart != null)
            {
                Panel labelArea = TreeHelper.FindDescendent(chart, "LabelArea_PART") as Panel;
                if (labelArea != null && this.ItemsSource != null)
                {
                    foreach (object dataItem in this.ItemsSource)
                    {
                        PieDataPoint pieDataPoint = this.GetDataPoint(dataItem) as PieDataPoint;
                        if (pieDataPoint != null)
                        {
                            this.AddLabelPieDataPoint(pieDataPoint, labelArea);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void IsLabeledPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            bool isLabeled = (bool)e.NewValue;

            if (isLabeled == true)
            {
                PieDataPoint pieDataPoint = obj as PieDataPoint;
                if (pieDataPoint != null)
                {
                    Chart chart = TreeHelper.FindAncestor <Chart>(pieDataPoint.Parent as DependencyObject);
                    if (chart != null)
                    {
                        //Panel labelArea = chart.Template.FindName("LabelArea_PART", chart) as Panel;
                        Panel labelArea = TreeHelper.FindDescendent(chart, "LabelArea_PART") as Panel;
                        if (labelArea != null)
                        {
                            AddLabel(pieDataPoint, labelArea);
                        }
                    }
                }
            }
        }