Pre loader

Constant sized Column bars

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
0

Hi,

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.

Thanks

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

Images
  • You must to post comments
Best Answer
3
0

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,
Yura.

  • 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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies