highCharts提示框中顯示當(dāng)前時(shí)間的方法
一、項(xiàng)目需求提示框中需要顯示當(dāng)前時(shí)間(常規(guī)的提示并不能達(dá)到這種效果)
樣式
二、知識(shí)點(diǎn)
highCharts圖表tooltip屬性中有一個(gè)formatter屬性
formatter: function() {……}
提示框內(nèi)容格式化回調(diào)函數(shù),返回 false 可以針對某個(gè)點(diǎn)或數(shù)據(jù)列關(guān)閉提示框,該函數(shù)里可以執(zhí)行復(fù)雜的邏輯來返回需要的內(nèi)容。
三、代碼
shared: true,//當(dāng)提示框被共享時(shí),整個(gè)繪圖區(qū)都將捕捉鼠標(biāo)指針的移動(dòng)。提示框文本顯示有序數(shù)據(jù)(不包括餅圖,散點(diǎn)圖和標(biāo)志圖等)的系列類型將被顯示在同一個(gè)提示框中。 formatter : function() {//提示框內(nèi)容格式化回調(diào)函數(shù),返回 false 可以針對某個(gè)點(diǎn)或數(shù)據(jù)列關(guān)閉提示框,該函數(shù)里可以執(zhí)行復(fù)雜的邏輯來返回需要的內(nèi)容。 var content = ''; for (var i = 0; i < this.points.length; i++) { if(i == this.points.length-1){ content += '<span style="font-size: 10px; color: ' + this.points[i].series.color + '">' + this.points[i].series.name + '</span>: ' + this.points[i].y +'℃'+'<br/>'; }else{ content += '<span style="font-size: 10px; color: ' + this.points[i].series.color + '">' + this.points[i].series.name + '</span>: ' + this.points[i].y +'%'+'<br/>'; } }; var date = new Date(); var nowYear=date.getFullYear().toString(); var nowMonth=(date.getMonth() + 1).toString(); var nowDay=date.getDate().toString(); var nowHours=date.getHours().toString(); var nowMin=date.getMinutes().toString(); var nowSeconds=date.getSeconds().toString(); function timeAdd0(str) { if(str.length<=1){ str='0'+str; } return str } nowYear=timeAdd0(nowYear) ; nowMonth=timeAdd0(nowMonth) ; nowDay=timeAdd0(nowDay) ; nowHours=timeAdd0(nowHours) ; nowMin=timeAdd0(nowMin); nowSeconds=timeAdd0(nowSeconds) content = '<span>' + nowYear + '/' + nowMonth + '/' + nowDay + ' ' + nowHours + ':' + nowMin + ':' + nowSeconds + ' year' + '</span><br/>' +content; return content; },
四、效果
若有不足請多多指教!希望給您帶來幫助!
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
- 在vue項(xiàng)目中引入highcharts圖表的方法(詳解)
- Vue 中使用vue2-highcharts實(shí)現(xiàn)top功能的示例
- Vue 中使用vue2-highcharts實(shí)現(xiàn)曲線數(shù)據(jù)展示的方法
- 在Vue中使用highCharts繪制3d餅圖的方法
- highcharts 在angular中的使用示例代碼
- 通過php動(dòng)態(tài)傳數(shù)據(jù)到highcharts
- jQuery插件HighCharts繪制簡單2D柱狀圖效果示例【附demo源碼】
- jQuery插件HighCharts繪制簡單2D折線圖效果示例【附demo源碼】
- jQuery插件HighCharts繪制2D餅圖效果示例【附demo源碼下載】
- jQuery插件HighCharts實(shí)現(xiàn)氣泡圖效果示例【附demo源碼】
相關(guān)文章
使用Vue父子組件通信實(shí)現(xiàn)todolist的功能示例代碼
這篇文章主要給大家介紹了關(guān)于如何使用Vue父子組件通信實(shí)現(xiàn)todolist的功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04Vue AST的轉(zhuǎn)換實(shí)現(xiàn)方法講解
本節(jié),我們將討論關(guān)于AST的轉(zhuǎn)換。所謂AST的轉(zhuǎn)換,指的是對AST進(jìn)行一系列操作,將其轉(zhuǎn)換為新的AST的過程。新的AST可以是原語言或原DSL的描述,也可以是其他語言或其他DSL的描述。例如,我們可以對模板AST進(jìn)行操作,將其轉(zhuǎn)換為JavaScriptAST2023-01-01