<HTML>
<HEAD>
<SCRIPT LANGUAGE="javascript">
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
function Body_Init(oSelect,oText)
{
var iLeft= oSelect.offsetLeft
var iTop = oSelect.offsetTop
var iWidth=oSelect.clientWidth
var iHeight=oSelect.clientHeight
oSelect.style.clip='rect(0,'+iWidth+','+iHeight+','+(iWidth-18)+')'
oText.style.width=iWidth
oText.style.height=iHeight
oText.style.top =iTop
oText.style.left=iLeft
}
function Combo_Select(oSelect,oText)
{
oText.value=oSelect.options[oSelect.selectedIndex].text
alert(oText.value)
}
function Text_ChkKey(oSelect,oText)
{
if(event.keyCode==13)
{
var nIndex=HasTheValue(oText.value,oSelect)
if(nIndex !=-1 &&nIndex !=oSelect.selectedIndex)
{
oSelect.selectedIndex=nIndex
}
}
}
function HasTheValue(name,oSelect)
{
if(oSelect.options.length<1)
return -1
var i=0
for(i=0i<oSelect.options.lengthi++)
{
if(oSelect.options[i].text==name)
return i
}
return -1
}
</SCRIPT>
</HEAD>
<BODY onload="javascript:Body_Init(pCombo,pText)">
<table width=50% width=50% align="center" valign="middle">
<tr><td>
<SELECT STYLE="position:absoluteleft:0top:0" ONCHANGE="Combo_Select(this,pText)" NAME="pCombo" >
<option value="d">test1</option>
<option value="dd">test2</option>
<option value="dd">asds</option>
<option value="dd">awdfsfs</option>
</SELECT>
<INPUT STYLE="position:absolute" onKeyPress="Text_ChkKey(pCombo,this)" TYPE="TEXT" NAME="pText">
</td></tr>
</table>
</BODY>
</HTML>
Chart.js允许通过HTML5的canvas进行图表绘制。这里我们希望绘制一个环形图,点击图上各segment时可以显示自定义的圆形tooltip。Chart.js支持通过几个变量添加tooltip,它提供一个tooltipTemplate但是却不支持自定义tooltip的HTML!于是决定自行绘制tooltip手动添加上去。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)