关于MS图上x轴上显示的值的问题 [英] problem about value shown on x-axis on MSchart

查看:79
本文介绍了关于MS图上x轴上显示的值的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这张照片是我的图表



http:// image。 ohozaa.com/view/86bve [ ^ ] <在x轴上的


是我从我的数据库查询的产品的名称。你可以看到右边的图表是一系列产品,有3个系列,但在x轴上有名称只显示一个产品。这是橙色系列的系列名称



This picture is my chart

http://image.ohozaa.com/view/86bve[^]

on x-axis is name of product that i query from my database. you can see the right of chart is a series of product that have 3 series but on x-axis have name show only one product .that is a series name for orange color series

string sql2 = "select NAME_Product from Product where  Product.ID_Product = '" + idtoselect + "' ";
                        SqlCommand testcommand2 = new SqlCommand(sql2, conn);
                        rdr = testcommand2.ExecuteReader();

                        if (rdr.Read())
                        {
                            test = rdr["NAME_Product"].ToString();
                        }
                        rdr.Close();
                            string sql = "SELECT NAME_Product,QUANTITY_Product FROM Product  where  Product.ID_Product = @ID";
                            da = new SqlDataAdapter(sql, conn);

                            da.SelectCommand.Parameters.AddWithValue("@ID", idtoselect);
                            datatb = new DataTable();
                            da.Fill(datatb);
                            da.Fill(datatb2);
       
                            chart1.Series.Add(test);
                            
                            for (int i = 0; i < datatb.Rows.Count; i++)
                            {
                                chart1.Series[test].Points.AddXY(datatb.Rows[i].ItemArray.GetValue(0), datatb.Rows[i].ItemArray.GetValue(1));
                                
                            }
                            chart1.Series[test].ChartArea = "ChartArea1";
                            chart1.Series[test].BorderWidth = 4;
                            chart1.Series[test].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
                            chart1.Series[test].YValueMembers = "QUANTITY_Product";
                            chart1.Series[test].XValueMember = "NAME_Product";
                            chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = 45;

      
                            chart1.DataBind();





我如何获得名称产品(所有系列)我有选择)在x轴上



请任何人帮助我



How can i get Name product(all series that i have select) on x-axis

Please any one to help me

推荐答案

全部显示在mschart中的X轴上跳过的标签



解决方案1: -

Show All Skipped Labels on the X-Axis in mschart

Solution 1:-
ChartName.ChartAreas(0).AxisX.Interval = 1





解决方案2: -



Solution 2:-

ChartName.ChartAreas(0).AxisX.Interval = Double.NaN
   ChartName.ChartAreas(0).AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount
     ChartName.ChartAreas(0).AxisX.LabelStyle.Angle = 90


这篇关于关于MS图上x轴上显示的值的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆