Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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

C#
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();


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

Please any one to help me
Posted
Updated 2-Feb-12 18:41pm
v3
Comments
ZurdoDev 2-Feb-12 8:16am    
What is the question?
pongpanut 2-Feb-12 8:44am    
How can i get Name product(all series that i have select) on x-axis
ZurdoDev 3-Feb-12 8:24am    
Still not sure what you are looking for. You can loop through the series in the chart, if that helps, but I don't understand what you need.
sunil gurjar 3-Feb-12 0:41am    
have u checked value of this "datatb.Rows[i].ItemArray.GetValue(1)" for all product
Rajesh Anuhya 3-Feb-12 1:27am    
Not clear..
--RA

1 solution

Show All Skipped Labels on the X-Axis in mschart

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


Solution 2:-
VB
ChartName.ChartAreas(0).AxisX.Interval = Double.NaN
   ChartName.ChartAreas(0).AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount
     ChartName.ChartAreas(0).AxisX.LabelStyle.Angle = 90
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900