I have a problem with FastColumnRenderableSeries. My chart displays random values in datetime.
Everything works well but at some point during the zoom out the bars begin to overlap:
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.
- Alitec Developer asked 7 years ago
- You must login to post comments
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
- Yuriy Zadereckiy answered 7 years ago
- You must login to post comments
Thank you for explanation. If it’s not a problem, please the code snippet.
- Alitec Developer answered 7 years ago
- You must login to post comments
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
- Yuriy Zadereckiy answered 7 years ago
- You must login to post comments
Please login first to submit.