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

0
0

I have a problem with FastColumnRenderableSeries. My chart displays random values in datetime.

enter image description here

Everything works well but at some point during the zoom out the bars begin to overlap:

enter image description here

I noticed that this only happens when we have several groups of data.

I recorded the video to better understand:

http://screencast.com/t/kJiaJik1o

and prepared sample project.

Version
4.1.1.8645
  • You must to post comments
0
0

Hi there,

Thanks for your question. This is the default behavior of ColumnSeries. If your data is unevenly spaced, it is expected that columns will overlap. For now, you can set DataPointWidth to a smaller value to try to prevent this.

Also, it is possible to override the GetColumnWidth(IPointSeries, IRenderPassData) method. The width of columns is granted to be less than the returned value. If you want, I can provide a code snippet with an example.

Best regards,
Yuriy

  • You must to post comments
0
0

Thank you for explanation. If it’s not a problem, please the code snippet.

  • You must to post comments
0
0

Hi there,

Please find the extended series class below:

public class ConstantWidthColumnRenderableSeries : FastColumnRenderableSeries
{
    private int bar_width;

    public static readonly DependencyProperty ColumnXWidthProperty = DependencyProperty.Register("ColumnXWidth", typeof(double), typeof(BaseColumnRenderableSeries), new PropertyMetadata(1.0));
    public static readonly DependencyProperty ColumnPXWidthProperty = DependencyProperty.Register("ColumnPXWidth", typeof(int), typeof(BaseColumnRenderableSeries), new PropertyMetadata(0));

    public double ColumnXWidth
    {
        get
        {
            return (double)GetValue(ColumnXWidthProperty);
        }
        set
        {
            SetValue(ColumnXWidthProperty, value);
        }
    }

    public int ColumnPXWidth
    {
        get
        {
            return (int)GetValue(ColumnPXWidthProperty);
        }
        set
        {
            SetValue(ColumnPXWidthProperty, value);
        }
    }

    protected override int GetColumnWidth(IPointSeries points, IRenderPassData renderPassData)
    {
        return bar_width;
    }

    protected override void InternalDraw(IRenderContext2D renderContext, IRenderPassData renderPassData)
    {
        if (ColumnPXWidth > 0)
            bar_width = ColumnPXWidth;
        else if (ColumnXWidth > 0)
        {
            var width1 = renderPassData.XCoordinateCalculator.GetCoordinate(1) - renderPassData.XCoordinateCalculator.GetCoordinate(0);
            bar_width = (int)Math.Ceiling(width1 * ColumnXWidth);
        }
        else
            bar_width = 1;

        base.InternalDraw(renderContext, renderPassData);
    }
}

Hope it gives you the idea. You can extend it and adjust to your needs.

Best regards,
Yuriy

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.