我有一个数据系列List<Tuple<string,double>>
,我从中创建一个XyDataSeries<double, double>
. 我使用以下LabelFormatter
.
public class SciChartCustomLabelFormatter : ILabelFormatter
{
private readonly string[] _xLabels;
public SciChartCustomLabelFormatter(string[] xLabels)
{
_xLabels = xLabels;
}
public void Init(IAxis parentAxis)
{
}
public void OnBeginAxisDraw()
{
}
public ITickLabelViewModel CreateDataContext(IComparable dataValue)
{
throw new NotImplementedException();
}
public ITickLabelViewModel UpdateDataContext(ITickLabelViewModel labelDataContext, IComparable dataValue)
{
throw new NotImplementedException();
}
public string FormatLabel(IComparable dataValue)
{
var index = (double)Convert.ChangeType(dataValue, typeof(double));
if (index >= 0 && index < _xLabels.Length)
return _xLabels[(int)index];
return index.ToString(CultureInfo.InvariantCulture);
}
public string FormatCursorLabel(IComparable dataValue)
{
var index = (double)Convert.ChangeType(dataValue, typeof(double));
if (index >= 0 && index < _xLabels.Length)
return _xLabels[(int)index];
return index.ToString(CultureInfo.InvariantCulture);
}
}
我想创建一个 FastColumnRenderableSeries
<sciChart:FastColumnRenderableSeries
x:Name="columnSeries" DataPointWidth="1"
SeriesColor="#A99A8A" Opacity="0.5"
XAxisId="BottomAxisId"
YAxisId="LeftAxisId"
DataSeries="{Binding Series}">
</sciChart:FastColumnRenderableSeries>
将字符串用作列系列的标签。
目前,我可以用 YAxis 清楚地显示值来显示系列。但是如何使用标签格式化程序来显示 XAxis 字符串?我不知道我应该如何处理这些方法:
public ITickLabelViewModel CreateDataContext(IComparable dataValue)
和
public ITickLabelViewModel UpdateDataContext(ITickLabelViewModel labelDataContext, IComparable dataValue)
我正在尝试在这里创建一个帕累托图。