SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components



I’m trying to have constant sized column bars. As far as I know, the only property to change the X size of a bar is to use DataPointWidth which is a float between 0 and 1. It’s stated that it “Gets or sets the DataPointWidth, a value between 0.0 and 1.0 which defines the fraction of available space each column should occupy”.

But if I add two bars in the series, the available space shrinks, causing the bars to look thinner than the other series which only has 1 bar, creating an inconsistent look. It’s not a problem when I have equal number of bars in the series of course.

Is there a way to get around this problem, ideally I would have liked to have the DataPointWidth to accept the amount of X value it should be covering.

I’ve considered using the PalletteProvider with a single series, but it only returns Color, and I want to return Brush (for gradient effect). Also, I don’t want to change the border color. I couldn’t get it to work anyway, I’m probably missing something though,

I’ve set the

 renderer.PalletteProvider = new ProviderImplementation()

But it didn’t even hit the break points, but since I wasn’t interested in solid colors, decided to not pursue that.


Edit: I’m using, I’ve added my PalletteProviderImplementation, I’ts not hitting any of those breakpoints.

  • You must to post comments
Best Answer

Hi there,

Unfotunately column series doesn’t support this behavior out of the box. But you could easily implement it by overriding GetColumnWidth method:

public class ConstantColumnRenderableSeries : FastColumnRenderableSeries
    public static readonly DependencyProperty ColumnWidthProperty = DependencyProperty.Register(
        "ColumnWidth", typeof (IComparable), typeof (ConstantColumnRenderableSeries), new PropertyMetadata(default(IComparable), OnInvalidateParentSurface));

    public IComparable ColumnWidth
        get { return (IComparable) GetValue(ColumnWidthProperty); }
        set { SetValue(ColumnWidthProperty, value); }

    protected override double GetColumnWidth(IPointSeries points, IRenderPassData renderPassData)
        ICoordinateCalculator<double> xCoordinateCalculator = renderPassData.XCoordinateCalculator;

        var value = ConvertToDouble(ColumnWidth);

        return xCoordinateCalculator.GetCoordinate(value) - xCoordinateCalculator.GetCoordinate(0);

    private static double ConvertToDouble(IComparable comparable)
        if (comparable == null)
            return 0;

        if (comparable is DateTime)
            return ((DateTime)comparable).Ticks;

        if (comparable is TimeSpan)
            return ((TimeSpan)comparable).Ticks;

        return Convert.ToDouble(comparable, CultureInfo.InvariantCulture);

Then you just need to use it instead of FastColumnRenderabeSeries.

Best regards,

  • kewur
    exactly what I was looking for, Thank you.
  • Alexander Gulbit
    How can I do the same but with ColumnRenderableSeriesViewModel?
  • Atle Rudshaug
    I’m also wondering how to do this with ColumnRenderableSeriesViewModel.
  • Atle Rudshaug
    I managed by inheriting FastColumnRenderableSeriesForMvvm in the code above and then creating a FastColumnRenderableSeriesViewModel which interits ColumnRenderableSeriesViewModel and override ViewType to return typeof(ConstantColumnRenderableSeries). I don’t know how to be able to bind to ColumnWidth though.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.