0

我在我的 Asp.net 页面上显示一个柱形图表。代码如下:

private DataSet FetchDummyChartData()
    {
        DataSet ds = new DataSet();
        DataTable table = new DataTable();
        table.Columns.Add("Product", typeof(string));
        table.Columns.Add("Status", typeof(string));
        table.Columns.Add("Count", typeof(int));
        table.Rows.Add("FRA", "Completed", 20);
        table.Rows.Add("FRA", "Exceptions", 10);
        table.Rows.Add("Swaption", "Exceptions", 15);
        table.Rows.Add("Swaption", "Completed", 50);
        table.Rows.Add("Cap/Floor", "Exceptions", 40);
        table.Rows.Add("Cap/Floor", "Approval Pending", 10);
        table.Rows.Add("Single currency swap", "Completed", 70);
        table.Rows.Add("Single currency swap", "Approval Pending", 30);
        table.Rows.Add("Cross currency swap", "Completed", 60);
        table.Rows.Add("Cross currency swap", "Exceptions", 20);
        table.Rows.Add("IRS", "Completed", 40);
        table.Rows.Add("IRS", "Approval Pending", 70);
        table.Rows.Add("Single currency Option", "Completed", 70);
        table.Rows.Add("Single currency Option", "Exceptions", 50);
        table.Rows.Add("Some Derivative", "Completed", 40);
        table.Rows.Add("Some Derivative", "Exceptions", 10);
        table.Rows.Add("Some Derivative", "Approval Pending", 50);
        ds.Tables.Add(table);

        return ds;
    }
 Chart2.DataBindCrossTable(new DataView(FetchDummyChartData().Tables[0]), "Status", "Product", "Count", null);

问题是,如果 X 轴上的项目包含大于 3-4 个项目(这里的项目“FRA”、“IRS”等代表 X 轴),则不会显示最后一列。请注意,这是一个多线图。这是非常奇怪的行为。没有 CSS/空间问题,我检查过了。

这是屏幕截图: 在此处输入图像描述

4

1 回答 1

1

问题是您正在对数据进行分组,Status但在. 所以在系列中有。现在你可以使用StatusProductX axisEmptyPoints

Chart2.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "series name");

但是 theIntervalTypeenumNumber,等预定义的YearsMonths但我们IntervalType应该是Status。我还没有检查是否可以定义 custom IntervalType,所以最好的办法是检查表格中Status每个条目的Product缺失 DataTable并用默认值填充它们,然后图表将正确显示。

table.Rows.Add("FRA", "Completed", 20);
table.Rows.Add("FRA", "Exceptions", 10);
table.Rows.Add("FRA", "Approval Pending", 0);

table.Rows.Add("Swaption", "Exceptions", 15);
table.Rows.Add("Swaption", "Completed", 50);
table.Rows.Add("Swaption", "Approval Pending", 0);

table.Rows.Add("Cap/Floor", "Exceptions", 40);
table.Rows.Add("Cap/Floor", "Approval Pending", 10);
table.Rows.Add("Cap/Floor", "Completed", 0);

table.Rows.Add("Single currency swap", "Completed", 70);
table.Rows.Add("Single currency swap", "Approval Pending", 30);
table.Rows.Add("Single currency swap", "Exceptions", 0);

table.Rows.Add("Cross currency swap", "Exceptions", 20);
table.Rows.Add("Cross currency swap", "Completed", 0);
table.Rows.Add("Cross currency swap", "Approval Pending", 0);

table.Rows.Add("IRS", "Completed", 40);
table.Rows.Add("IRS", "Approval Pending", 70);
table.Rows.Add("IRS", "Exceptions", 0);

table.Rows.Add("Single currency Option", "Completed", 70);
table.Rows.Add("Single currency Option", "Exceptions", 50);
table.Rows.Add("Single currency Option", "Approval Pending", 0);

table.Rows.Add("Some Derivative", "Completed", 40);
table.Rows.Add("Some Derivative", "Exceptions", 10);
table.Rows.Add("Some Derivative", "Approval Pending", 50);
于 2013-08-07T08:57:21.020 回答