我一直在寻找某种教程,重点讨论工具提示如何工作,但没有多少运气。如何使鼠标悬停在数据点上时显示工具提示
我有一个测试项目,我用五个数据点渲染折线图。当我实例化Chart
对象时,我设置了IsMapEnabled = true
。当我定义系列时,我尝试设置工具提示。
private void DefineSeries() {
var series = new Series();
series.ToolTip = "#VALY";
series.PostBackValue = "#Index";
var x = new[] {0, 1, 2, 3, 4, 5};
var y = new[] {0, 4, 5, 3, 7, 2};
for (int i = 0; i < x.Length; i++) {
series.Points.Add(new DataPoint(x[ i ], y[ i ]));
}
series.ChartType = SeriesChartType.Line;
DefineSeriesStyle(series);
chart_.Series.Add(series);
}
该图表按预期呈现,但鼠标悬停在数据点上时不显示工具提示。我显然错过了某个步骤,但我不知道它是什么。
编辑:显示图表视图模型和后续函数调用的Action方法和构造函数的代码。
public ActionResult CausedOutPoint() {
var causedOut = new CausedOutViewModel();
var path = Server.MapPath("~") + "CausedOut.Png";
causedOut.Chart.SaveImage(path, ChartImageFormat.Png);
return File(path, "img/png");
}
public CausedOutViewModel() {
chart_ = new Chart {IsMapEnabled = true};
chart_.PostPaint += chart__PostPaint;
chart_.RenderType = RenderType.ImageMap;
chart_.ID = "CausedOut";
InitializeChart(chart_);
chart_.Width = new Unit(1200, UnitType.Pixel);
chart_.Height = new Unit(800, UnitType.Pixel);
CreateTitles();
}
private void InitializeChart() {
DefineSeries();
DefineChartArea();
}
必要剃刀你设置一个ID为'图表',如在[MSChart/Asp.net图表不显示工具提示](http://stackoverflow.com/questions/9456506/mschart-asp-net-charts-dont-show-tooltips )? –
我在搜索过程中看到了这一点。我试了一下,仍然没有。 – BrianM