首页 > 解决方案 > Stackedcolumn 图表有间隙并且 y 值不是从 0 开始

问题描述

我的数据库中有这样的数据:

但是当我在stackedcolumn上输出它时,我得到了这个结果,它有间隙,它没有从0开始

这是我的代码:

   string query = "SELECT * FROM TBL_SAMPLE INNER JOIN TBL_AREA ON TBL_SAMPLE.AREA = TBL_AREA.AREA";
            DataTable dt = GetData(query);

            //Get the DISTINCT Foods.
            List<string> countries = (from p in dt.AsEnumerable()
                                      select p.Field<string>("FOOD")).Distinct().ToList();

            //Loop through the Foods.
            foreach (string food in countries)
            {




                //Add Series to the Chart.
                Chart1.Series.Add(new Series(food));
                Chart1.Series[food].IsValueShownAsLabel = true;


                //Get the Area for each Food.
                int[] x = (from p in dt.AsEnumerable()
                           where p.Field<string>("FOOD") == food
                           select p.Field<int>("AREA_ID")).ToArray();

                //Get the Total each food.
                int[] y = (from p in dt.AsEnumerable()
                           where p.Field<string>("FOOD") == food
                           select p.Field<int>("TOTAL")).ToArray();


                Chart1.Series[food].ChartType = SeriesChartType.StackedColumn;
                Chart1.Series[food].Points.DataBindXY(x, y);


            }

            Chart1.Legends[0].Enabled = true;

标签: c#asp.net

解决方案


推荐阅读