我正在wpf用户控件中使用开源库LiveCharts。
我的所有可视化效果均符合预期,但箱形图除外。由于某些原因,我的箱线图上的图例颜色与实际系列不匹配。
在裸露的骨骼测试应用程序中,它看起来像这样。
这是我设置图表并填充它的方式。
public MainWindow()
{
chart1 = new Chart();
var testValues = new List<KeyValuePair<string, List<double>>>();
testValues.Add(new KeyValuePair<string, List<double>>("test", new List<double>() { 40, 30, 20, 10, 500 }));
testValues.Add(new KeyValuePair<string, List<double>>("tust", new List<double>() { 80, 10, 90, 30, 50 }));
chart1.AddBoxplotSeries(testValues, "titel");
}
public void AddBoxplotSeries(List<KeyValuePair<string, List<double>>> data, string title)
{
CartesianVisibility = Visibility.Visible;
ChartValues<OhlcPoint> values = new ChartValues<OhlcPoint>();
string[] labels = new string[data.Count];
//ChartValues<OhlcPoint> values = new ChartValues<OhlcPoint>();
foreach (var item in data)
{
double[] ohlc = new double[4];
ohlc[0] = item.Value.LowerQuartile();
ohlc[1] = item.Value.Maximum();
ohlc[2] = item.Value.Minimum();
ohlc[3] = item.Value.UpperQuartile();
labels[data.IndexOf(item)] = data[data.IndexOf(item)].Key;
values.Add(new OhlcPoint( ohlc[0], ohlc[1], ohlc[2], ohlc[3] ));
}
CartesianSeries.Add(new CandleSeries()
{
Values = values,
Title = title
});
XAxisLabels = labels;
LabelFormatter = value => value.ToString("N");
}
我做错了还是这是一个错误?