Charts 如何使用静态参数创建图表

Charts 如何使用静态参数创建图表,charts,telerik-reporting,telerik-charting,Charts,Telerik Reporting,Telerik Charting,我正在尝试创建一个telerik报告甜甜圈图表。问题是,我的值不是预期的格式 我的数据如下所示: { GoodHours: 120, Downtime: 43.5, PlannedTime: 12.77 } { Time: 60, Type: "GoodHours", Time: 45, Type: "GoodHours", Time: 43.5, Type: "Downtime", Time: 15, Type: "GoodHours", Time:

我正在尝试创建一个telerik报告甜甜圈图表。问题是,我的值不是预期的格式

我的数据如下所示:

{ GoodHours: 120, Downtime: 43.5, PlannedTime: 12.77 }
{ 
    Time: 60, Type: "GoodHours",
    Time: 45, Type: "GoodHours",
    Time: 43.5, Type: "Downtime",
    Time: 15, Type: "GoodHours",
    Time: 12.77, Type: "PlannedTime"
}
图表的设置方式似乎期望得到如下数据:

{ GoodHours: 120, Downtime: 43.5, PlannedTime: 12.77 }
{ 
    Time: 60, Type: "GoodHours",
    Time: 45, Type: "GoodHours",
    Time: 43.5, Type: "Downtime",
    Time: 15, Type: "GoodHours",
    Time: 12.77, Type: "PlannedTime"
}
我的数据以这种方式格式化的原因是,它来自一个相当复杂的存储过程,在将数据发送到报表之前,该存储过程本身会进行记录聚合。让MsSql处理数据要比让telerik reporting处理数据快得多

我甚至不知道如何开始设置图表

我按照在线说明创建了一个甜甜圈(饼)图,但它假设我的数据尚未消化。我尝试添加多个
系列
,但它们最终显示在不同的级别上,有点像甜甜圈中的甜甜圈


我如何设置它?

首先,编写存储过程并从C代码调用它

创建可序列化对象以存储SP中的数据

[Serializable()]
public class reportTimeTypeObj
{
    public decimal time { get; set; }
    public string type { get; set; }
}
然后创建一个函数来使用数据并将其转换为所需的格式

public List<reportTimeTypeObj> getTimeSpentPatientByVisitTypeObj()
{
    //Create a list of objects for your donut.
    reportTimeTypeObj list = new List<reportTimeTypeObj>();

    //Add code to call stored procedure here
    //ds is the data set returned from the stored procedure

    if (ds.Tables.Count > 0)
        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            list.Add(new reportTimeSpentPatientByVisitTypeObj()
            {
                time = dr["time "] != DBNull.Value ?
                                Convert.ToDecimal(dr["time "]) : 0,
                type = dr["type "] != DBNull.Value ? 
                            string.IsNullOrEmpty(dr["visit_type"].ToString()) ?
                            "Not recorded" :
                            Convert.ToString(dr["visit_type"]) : "Not recorded"
        });
    }
    return list;
}
public List getTimeSpentPatientByVisitTypeObj()
{
//为你的甜甜圈创建一个对象列表。
reportTimeTypeObj list=新列表();
//在此处添加调用存储过程的代码
//ds是从存储过程返回的数据集
如果(ds.Tables.Count>0)
foreach(ds.Tables[0].行中的数据行dr)
{
添加(新的ReportTimePentPatientByVisitTypeObj()报告)
{
time=dr[“time”]!=DBNull.Value?
转换.ToDecimal(dr[“time”]):0,
type=dr[“type”]!=DBNull.Value?
string.IsNullOrEmpty(dr[“visit_type”].ToString())?
“未记录”:
Convert.ToString(dr[“访问类型”]):“未记录”
});
}
退货清单;
}
接下来,使用报表设计器创建ObjectDataSource(ODS)组件。将该功能分配给ODS。按照以下步骤创建图表

接下来,右键单击饼图。单击“更改图表类型…”。在选项显示中,选择油炸圈饼图表