Hi
I’ve followed your example for a Custom Label on X axis , I changed from the init parameter from IAxis to IAxisCore as defined in ProviderBase, otherwise it wouldn’t have compile. But after passing from public override string FormatLabel I got this error
Unable to cast object of type 'SciChart.Charting.Visuals.Axes.LabelProviders.DefaultTickLabelViewModel' to type 'SciChart.Charting.Visuals.Axes.LabelProviders.NumericTickLabelViewModel'.
Here my definition of the XAxis
<s:NumericAxis x:Name="MainChartXAxis"
VisibleRangeChanged="XAxis_VisibleRangeChanged"
AutoTicks="False"
AxisTitle="Programming Language"
LabelProvider="{Binding XLabelFormatter}"
MajorDelta="1"
MinorDelta="0.2"
VisibleRange="-0.5,4.5"
>
</s:NumericAxis>
I have a BaseRenderableSeries defined as follows
<s:SciChartSurface Name="sciChart"
Grid.Row="0"
BorderThickness="0"
Padding="0"
s:SciChartGroup.VerticalChartGroup="myCharts"
>
<!-- Declare RenderableSeries -->
<s:SciChartSurface.RenderableSeries>
<s:FastLineRenderableSeries x:Name="lineSeries"
StrokeThickness="2"
PaletteProvider="{StaticResource GainLossPaletteProvider}"
s:CursorModifier.TooltipTemplate="{StaticResource CursorTooltipTemplate}"
>
<s:FastLineRenderableSeries.PointMarker>
<seriesWithMetadata:AnnotatedPointMarker RenderPD="{Binding ElementName=lineSeries,Path=.}" Width="5" Height="7" GainMarkerFill="LimeGreen" LossMarkerFill="Red" Stroke="White" StrokeThickness="1"/>
</s:FastLineRenderableSeries.PointMarker>
</s:FastLineRenderableSeries>
<s:FastLineRenderableSeries x:Name="FastLineSeries" />
</s:SciChartSurface.RenderableSeries>
am I doing something wrong?
- lorenzo522 asked 8 years ago
- You must login to post comments
Hi Lorenzo,
The Heatmap With Text example in our WPF Examples Suite actually includes a LabelProvider. If you have a look at the source-code, it can help you.
The LabelProvider is declared like this
class YAxisLabelProvider: LabelProviderBase
{
public override string FormatLabel(IComparable dataValue)
{
var day = Convert.ToInt32(dataValue);
switch (day)
{
case 0: return "Mon";
case 1: return "Tue";
case 2: return "Wed";
case 3: return "Thu";
case 4: return "Fri";
case 5: return "Sat";
case 6: return "Sun";
}
return "";
}
public override string FormatCursorLabel(IComparable dataValue)
{
return FormatLabel(dataValue);
}
}
class XAxisLabelProvider : LabelProviderBase
{
public override string FormatLabel(IComparable dataValue)
{
var h = Convert.ToInt32(dataValue);
var dt = new DateTime(2000, 1, 1, 1, 0, 0).AddHours(h);
return dt.ToString("hh:mm tt", new CultureInfo("en-US"));
}
public override string FormatCursorLabel(IComparable dataValue)
{
return FormatLabel(dataValue);
}
}
And assigned like this
yAxis.LabelProvider = new YAxisLabelProvider();
- Andrew Burnett-Thompson answered 8 years ago
-
That was what I was looking for. Thank you
- You must login to post comments
Please login first to submit.