饼图未正确显示

时间:2014-04-17 21:08:54

标签: highcharts

我是新手并尝试使用饼图。以下代码仅显示一块饼图而非完整饼图。我无法在代码中发现任何错误。如果有人能帮助我,我将非常感激。 提前谢谢。

    protected void Page_Load(object sender, EventArgs e)
    {

        try
        {
            string connect = "DATABASE=PDS;SERVER='abcd';User Id=******;Password=******;";

            SqlConnection scn = new SqlConnection(connect);  

            scn.Open();

            string sp = "GetGenderCount";

            SqlCommand spcmd = new SqlCommand(sp, scn);

            SqlParameter Load_id = new SqlParameter("@Load_id", SqlDbType.Char);
            Load_id.Value = "122574";
            spcmd.Parameters.Add(Load_id);

            SqlParameter Hospital_id = new SqlParameter("@Hospital_id", SqlDbType.Char);
            Hospital_id.Value = "050103";
            spcmd.Parameters.Add(Hospital_id);

            //SqlParameter YearMonth = new SqlParameter("@YearMonth", SqlDbType.Char);
            //YearMonth.Value = "200904";
            //spcmd.Parameters.Add(YearMonth);

            spcmd.CommandType = CommandType.StoredProcedure;

            SqlDataAdapter da = new SqlDataAdapter(spcmd);

            DataSet ds = new DataSet();
            da.Fill(ds);

            scn.Close();

            Int32 totalArraySize = ds.Tables[0].Rows.Count;
            Object[] XAxisData = new object[totalArraySize];
            Object[] YAxisServices = new object[totalArraySize];
            int J = 0;
            foreach (DataRow drRow in ds.Tables[0].Rows)
            {
                YAxisServices[J] = new object[] { (drRow[0].ToString()), (drRow[J].ToString()) };
                J += 1; ;
            }
            Highchart.Core.SerieCollection series = new Highchart.Core.SerieCollection();
            Highchart.Core.Data.Chart.Serie serieServices = new Highchart.Core.Data.Chart.Serie();
            serieServices.size = 130;
            serieServices.data = YAxisServices;
            serieServices.type = RenderType.pie;
            serieServices.name = "";
            serieServices.showInLegend = false;
            series.Add(serieServices);

            Chart.PlotOptions = new Highchart.Core.PlotOptions.PlotOptionsPie
            {
                allowPointSelect = true,
                cursor = "pointer",
                dataLabels = new Highchart.Core.PlotOptions.DataLabels { enabled = true, formatter = "this.point.name" },
                animation = false
            };
            Chart.Tooltip = new ToolTip("this.point.name +': '+ this.y");
            Chart.DataSource = series;
            Chart.DataBind();
            Chart.Dispose();
        }
        catch (SqlException x)
        {
            string msg = x.Message;
        }
    }

0 个答案:

没有答案