我尝试在 jQuery 对话框上的 MsChart 上显示一些工具提示,但工具提示从不在对话框顶部。以下是我的总源代码。
<script type="text/javascript">
$(function () {
$("#dialog2").dialog({
autoOpen: true,
width: 640,
height: 'auto',
position: [100, 110]
});
for (var i = 0; i < $('area').length; i++) {
$('area:eq(' + i + ')').attr('id', 'area-id-' + i); //change id
$.data(this, 'area-title-' + i, $('area:eq(' + i + ')').attr('title')); //store title
if ($.data(this, 'area-title-' + i) != undefined) {
new YAHOO.widget.Tooltip("myTip", {
context: 'area-id-' + i,
text: "hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>hello<br/>",
width: 300,
container: this.dialog2,
autodismissdelay: 3600000, // show one hour
showdelay: 0
});
}
}
});
</script>
<div id="dialog2" title="my chart">
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<string> rom_list = new List<string>();
rom_list.Add("1.1");
rom_list.Add("1.2");
rom_list.Add("1.3");
rom_list.Add("1.4");
rom_list.Add("1.5");
List<double> value_list = new List<double>();
value_list.Add(4);
value_list.Add(2);
value_list.Add(6);
value_list.Add(3);
value_list.Add(8);
Chart1.Series[0].Points.DataBindXY(rom_list, value_list);
foreach (System.Web.UI.DataVisualization.Charting.DataPoint point in Chart1.Series[0].Points)
{
point.ToolTip = "this is tooltip " + point.YValues[0].ToString();
}
}
}