Example #1
0
        private static IList<TextLabel> GetLabels(Axis axis)
        {
            AxisScale scale = axis.Scale;
            IList<TextLabel> labels = null;
            TextScale textScale = scale as TextScale;
            if (textScale != null)
                labels = (textScale).Labels;

            return labels;
        }
Example #2
0
        private static AxisHitTestResult HandleAxisHit(Axis axis, UIElement element, Point point)
        {
            double value;
            if (element is FrameworkElement && ((FrameworkElement)element).Tag is double)
                value = (double)((FrameworkElement)element).Tag;  // The value for tick marks and tick labels is in the tag.
            else
                value = axis.GetValue(point);

            return new AxisHitTestResult
            {
                ChartPanel = GetChartPanel(axis),
                Axis = axis,
                Value = value,
                Visual = element,
            };
        }
        /// <summary>
        /// Sets the value of the <see cref="P:DigitalRune.Windows.Charts.ChartPanel.YAxis"/>
        /// attached property to a given element.
        /// </summary>
        /// <param name="element">The element on which to set the property value.</param>
        /// <param name="value">The property value to set.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="element"/> is <see langword="null"/>.
        /// </exception>
        public static void SetYAxis(DependencyObject element, Axis value)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            element.SetValue(YAxisProperty, value);
        }
Example #4
0
        public static Rect GetChartAreaBounds(Axis xAxis, Axis yAxis)
        {
            if (xAxis == null || yAxis == null)
                return Rect.Empty;

            if (xAxis.Orientation != Orientation.Horizontal)
                throw new ArgumentException("X-axis must be a horizontal axis.", "xAxis");
            if (yAxis.Orientation != Orientation.Vertical)
                throw new ArgumentException("Y-axis must be a vertical axis.", "yAxis");

            return new Rect(xAxis.OriginX, yAxis.OriginY - yAxis.Length, xAxis.Length, yAxis.Length);
        }
Example #5
0
        private static bool MatchesYAxis2(Axis axis)
        {
            var chartPanel = VisualTreeHelper.GetParent(axis) as DefaultChartPanel;
            if (chartPanel != null)
                return (chartPanel.YAxis2 == axis);

            return false;
        }
Example #6
0
 private static bool MatchesYAxes(Axis axis)
 {
     return (axis != null && axis.IsYAxis);
 }
Example #7
0
 private static bool MatchesNone(Axis axis)
 {
     return false;
 }
Example #8
0
 //--------------------------------------------------------------
 private static bool MatchesAll(Axis axis)
 {
     return true;
 }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultChartPanel"/> class.
        /// </summary>
        public DefaultChartPanel()
        {
            // Add the axis as the first canvas children.
            XAxis1 = new Axis { Tag = "XAxis1", LabelsAboveAxis = false, Orientation = Orientation.Horizontal };
            YAxis1 = new Axis { Tag = "YAxis1", LabelsAboveAxis = true, Orientation = Orientation.Vertical };
            XAxis2 = new Axis { Tag = "XAxis2", LabelsAboveAxis = true, Orientation = Orientation.Horizontal };
            YAxis2 = new Axis { Tag = "YAxis2", LabelsAboveAxis = false, Orientation = Orientation.Vertical };

            // Bind styles of axes
            Binding binding = new Binding("XAxis1Style") { Source = this };
            XAxis1.SetBinding(StyleProperty, binding);
            binding = new Binding("YAxis1Style") { Source = this };
            YAxis1.SetBinding(StyleProperty, binding);
            binding = new Binding("XAxis2Style") { Source = this };
            XAxis2.SetBinding(StyleProperty, binding);
            binding = new Binding("YAxis2Style") { Source = this };
            YAxis2.SetBinding(StyleProperty, binding);

            // Set z-index of axes (usually 0).
#if SILVERLIGHT
            Canvas.SetZIndex(XAxis1, AxisZIndex);
            Canvas.SetZIndex(YAxis1, AxisZIndex);
            Canvas.SetZIndex(XAxis2, AxisZIndex);
            Canvas.SetZIndex(YAxis2, AxisZIndex);
#else
            SetZIndex(XAxis1, AxisZIndex);
            SetZIndex(YAxis1, AxisZIndex);
            SetZIndex(XAxis2, AxisZIndex);
            SetZIndex(YAxis2, AxisZIndex);
#endif

            // Add axes as the first children of the panel.
            Children.Add(XAxis1);
            Children.Add(YAxis1);
            Children.Add(XAxis2);
            Children.Add(YAxis2);

            XAxis1.Invalidated += OnAxisInvalidated;
            YAxis1.Invalidated += OnAxisInvalidated;
            XAxis2.Invalidated += OnAxisInvalidated;
            YAxis2.Invalidated += OnAxisInvalidated;
        }