如何使用C#向BoxPlot图表添加工具提示 [英] How to Add Tooltip To BoxPlot Chart Using C#

查看:545
本文介绍了如何使用C#向BoxPlot图表添加工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我动态创建了箱形图,但是想在箱形图中添加工具提示,这样当用户将鼠标悬停在方块图系列上时,方块图系列值将会显示在工具提示中。



这是我创建箱形图的代码:





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:


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.

推荐答案

在你的代码中使用它,

Hi, Use this in your code,
chart1.Series[YourChartIndex].Points[Chart1_POINTINDEX].ToolTip = "Point Value";


这篇关于如何使用C#向BoxPlot图表添加工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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