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.
- kewur asked 9 years ago
- last edited 9 years ago
-
5
- You must login to post comments
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.
- Yura Khariton answered 9 years ago
-
exactly what I was looking for, Thank you.
-
How can I do the same but with ColumnRenderableSeriesViewModel?
-
I’m also wondering how to do this with ColumnRenderableSeriesViewModel.
-
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 login to post comments
Please login first to submit.