我正在尝试根据以下数据创建堆积柱形图 PrimaryAdvisorName AccountTypeName TotalCustodianValue 保罗T1 100 约翰T2 200 约翰T3 300
但我遇到的问题是所有系列都堆叠在同一个x轴标签上。我看不到其他x轴值
|
|
| | |
| | |
| | |
-------------
保罗
foreach (ProfileLineItem x in data.LineItems)
{
Series s = new Series
{
Name = x.AccountTypeName,
ChartType = SeriesChartType.StackedColumn,
Font = new Font("Segoe UI", 8),
CustomProperties = "DrawingStyle=Cylinder",
Legend = "Default",
ChartArea="Default"
};
string xVal = x.PrimaryAdvisorName;
bool found = false;
foreach (Series t in stackedColumnChart.Series)
{
foreach (DataPoint dt in t.Points)
{
if (xVal == dt.AxisLabel)
{
found = true;
break;
}
}
if(found)
{
var y2 = data.LineItems.Where(i => (i.PrimaryAdvisorName.Equals(xVal) && i.AccountTypeName.Equals(x.AccountTypeName)))
.Select(k => k.TotalCustodianValue);
foreach (double d in y2)
{
s.Points.AddXY(xVal, d);
}
break;
}
}
if (!found)
{
var y2 = data.LineItems.Where(i => (i.PrimaryAdvisorName.Equals(xVal) && i.AccountTypeName.Equals(x.AccountTypeName)))
.Select(k => k.TotalCustodianValue);
foreach (double d in y2)
{
s.Points.AddXY(xVal, d);
}
}
stackedColumnChart.Series.Add(s);
}