Ejemplo n.º 1
0
        protected override void OnPrepareBar(int index, DataPoint data, FrameworkElement bar)
        {
            double paletteIndex;

            switch (PaletteIndex)
            {
            case PaletteIndex.Index:
                paletteIndex = index;
                break;

            case PaletteIndex.XValue:
                paletteIndex = data.X;
                break;

            case PaletteIndex.YValue:
                paletteIndex = data.Y;
                break;

            default:
                throw new NotSupportedException("PaletteIndex type is not supported.");
            }

            Brush fillBrush;
            Brush strokeBrush;

            GetBrushes(paletteIndex, out strokeBrush, out fillBrush);
            ChartHelper.SetStrokeAndFill(bar, strokeBrush, fillBrush);
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        protected override UIElement OnGetLegendSymbol()
        {
            if (DataPointTemplate != null)
            {
                var grid = new Grid
                {
                    MinWidth  = 16,
                    MinHeight = 16,
                };

                var legendSymbol = CreateDataPoint(null) ?? new Rectangle();
                legendSymbol.Width  = 16;
                legendSymbol.Height = 10;
                legendSymbol.HorizontalAlignment = HorizontalAlignment.Center;
                legendSymbol.VerticalAlignment   = VerticalAlignment.Center;
                legendSymbol.SetBinding(StyleProperty, new Binding("DataPointStyle")
                {
                    Source = this
                });
                legendSymbol.IsHitTestVisible = false;

                Brush fillBrush   = null;
                Brush strokeBrush = null;

                Palette fillPalette = EffectiveFillPalette;
                if (fillPalette != null && fillPalette.Count > 0)
                {
                    double start = fillPalette[0].Value;
                    double end   = fillPalette[fillPalette.Count - 1].Value;
                    fillBrush = new LinearGradientBrush
                    {
                        GradientStops          = fillPalette.GetGradient(start, end),
                        StartPoint             = new Point(0, 0.5),
                        EndPoint               = new Point(1, 0.5),
                        ColorInterpolationMode = fillPalette.ColorInterpolationMode
                    };
                }

                Palette strokePalette = EffectiveStrokePalette;
                if (strokePalette != null && strokePalette.Count > 0)
                {
                    double start = strokePalette[0].Value;
                    double end   = strokePalette[strokePalette.Count - 1].Value;
                    strokeBrush = new LinearGradientBrush
                    {
                        GradientStops          = strokePalette.GetGradient(start, end),
                        StartPoint             = new Point(0, 0.5),
                        EndPoint               = new Point(1, 0.5),
                        ColorInterpolationMode = strokePalette.ColorInterpolationMode
                    };
                }

                ChartHelper.SetStrokeAndFill(legendSymbol, strokeBrush, fillBrush);

                grid.Children.Add(legendSymbol);
                return(grid);
            }

            return(base.OnGetLegendSymbol());
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        protected override UIElement OnGetLegendSymbol()
        {
            if (DataPointTemplate != null)
            {
                var grid = new Grid
                {
                    MinWidth  = 16,
                    MinHeight = 16,
                };

                var legendSymbol = CreateDataPoint(null) ?? new Rectangle();
                if (EffectiveOrientation == Orientation.Vertical)
                {
                    legendSymbol.Width  = 10;
                    legendSymbol.Height = 14;
                    legendSymbol.HorizontalAlignment = HorizontalAlignment.Center;
                    legendSymbol.VerticalAlignment   = VerticalAlignment.Bottom;
                }
                else
                {
                    legendSymbol.Width  = 14;
                    legendSymbol.Height = 10;
                    legendSymbol.HorizontalAlignment = HorizontalAlignment.Left;
                    legendSymbol.VerticalAlignment   = VerticalAlignment.Center;
                }
                legendSymbol.SetBinding(StyleProperty, new Binding("DataPointStyle")
                {
                    Source = this
                });
                legendSymbol.IsHitTestVisible = false;

                double paletteIndex = 1;
                if (FillPalette != null && FillPalette.Count > 0)
                {
                    paletteIndex = FillPalette[FillPalette.Count - 1].Value;
                }
                else if (StrokePalette != null && StrokePalette.Count > 0)
                {
                    paletteIndex = StrokePalette[StrokePalette.Count - 1].Value;
                }

                Brush fillBrush;
                Brush strokeBrush;
                GetBrushes(paletteIndex, out strokeBrush, out fillBrush);
                ChartHelper.SetStrokeAndFill(legendSymbol, strokeBrush, fillBrush);

                grid.Children.Add(legendSymbol);
                return(grid);
            }

            return(base.OnGetLegendSymbol());
        }