I am trying to create a stacked column chart from the following data.
PrimaryAdvisorName AccountTypeName TotalCustodianValue
Paul T1 100
John T2 200
John T3 300
but the issue I am facing is all the series gets stacked on the same x-axis label.I don't see other x-axis values
|
|
| | |
| | |
| | |
-------------
Paul
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);
}