我一直在尋找某種教程,重點討論工具提示如何工作,但沒有多少運氣。如何使鼠標懸停在數據點上時顯示工具提示
我有一個測試項目,我用五個數據點渲染折線圖。當我實例化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