Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all,
I have created box plot chart dynamically but would like to add a tooltip to the box plot chart so that when user mouse over the box plot series, the box plot series values will be displayed out in tooltip.

This is my code to create box plot chart:


C#
Chart Chart1= new Chart();
                        Chart1.DataSource = dt;
                        Chart1.Width = 800;
                        Chart1.Height = 490;

                        Chart1.Series.Add(new Series());
                        Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;
                        Chart1.Series.Add(new Series());
                        Chart1.Series[1].ChartType = SeriesChartType.Point;
                        List<object> List1 = dt.AsEnumerable().ToList<object>();

                        int Chart1_AVG = 0;
                        int Chart1_POINTINDEX = 0;

                        foreach (DataRow row in dt.Rows)
                        {
                            Chart1_AVG = (int)row["AVG"];

                            Chart1.Series[0].Points.AddXY(row["CUSTOMER"], new object[] { row["MIN"], row["MAX"], row["25TH_PCT_NUMBER"], row["75TH_PCT_NUMBER"], row["50TH_PCT_NUMBER"], row["AVG"] });
                            Chart1_POINTINDEX = Chart1.Series[1].Points.AddXY(row["CUSTOMER"], new object[] { row["AVG"] });

                            if ((Chart1_AVG >= AvgMinColorGreen) && (Chart1_AVG <= AvgMaxColorGreen))
                            {
                                Chart1.Series[1].Points[Chart1_POINTINDEX].MarkerColor = Color.Green;
                            }
                            else if ((Chart1_AVG >= AvgMinColorYellow) && (Chart1_AVG <= AvgMaxColorYellow))
                            {
                                Chart1.Series[1].Points[Chart1_POINTINDEX].MarkerColor = Color.Orange;
                            }
                            else if ((Chart1_AVG >= AvgMinColorRed) && (Chart1_AVG <= AvgMaxColorRed))
                            {
                                Chart1.Series[1].Points[Chart1_POINTINDEX].MarkerColor = Color.Red;
                            }
                        }
                        Chart1.Series[0]["BoxPlotShowMedian"] = "false"; //hide the average point

                        //create chartareas
                        ChartArea ca= new ChartArea();

                        //databind
                        Chart1.DataBind();
                        Chart1.Visible = true;

                        panel.Controls.Add(Chart1);

Please help me on this, thanks.
Posted
Comments
VR Karthikeyan 30-Oct-15 2:04am    
Refer your Chart's documentation
Member 11999641 30-Oct-15 2:09am    
hi VR Karthikeyan, may I know what do you mean by chart's documentation?
VR Karthikeyan 30-Oct-15 2:31am    
Chart is an User Interface Component, It must contains documentation to instruct developers on the usage of that component. What is the namespace or library you are using to create chart? If you using any 3rd party charts, you can search for how to use the chart in their website, it will gives you needed information.
gggustafson 4-Nov-15 14:06pm    
It would be better for you to provide help rather than some smug answer!
VR Karthikeyan 4-Nov-15 23:22pm    
Can you specify the namespace of the Chart control?

1 solution

Hi, Use this in your code,
C#
chart1.Series[YourChartIndex].Points[Chart1_POINTINDEX].ToolTip = "Point Value";
 
Share this answer
 
Comments
Member 11999641 6-Nov-15 1:37am    
hi VR Karthikeyan, thanks for your help in this! :) solved this issue.

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