2

我正在尝试从以下数据创建堆积柱形图。
PrimaryAdvisorName AccountTypeName TotalCustodianValue Paul T1 100 John T2 200 John 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);

            }
4

0 回答 0