2017-10-10 124 views
0

我對我的網站上的圖表有疑問: 我想在這張圖片的工具提示上加粗和下劃線。如何加下劃線和粗體工具提示圖表js

ChartJs圖片: enter image description here

我發現這是非常有可能採取:tooltipTitleFontStyle: 「大膽」titleFontStyle: '大膽'但沒有工作。

你有解決方案嗎?

回答

0

嗨,你可以建立自己的工具提示,以便它返回無論你想,即自定義HTML

http://www.chartjs.org/docs/latest/configuration/tooltip.html#external-custom-tooltips

的字體爲粗體titleFontStyle的選項必須在裏面options.tooltips:

var options = { 
    type: 'line', 
    data: { 
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], 
    datasets: [ 
     { 
      label: '# of Votes', 
      data: [12, 19, 3, 5, 2, 3], 
     borderWidth: 1 
     }, 
      { 
       label: '# of Points', 
       data: [7, 11, 5, 8, 3, 7], 
       borderWidth: 1 
      } 
     ] 
    }, 
    options: { 
    scales: { 
     yAxes: [{ 
     ticks: { 
        reverse: false 
     } 
     }] 
    }, 
    tooltips: { 
     titleFontStyle: 'bold', 
     titleFontSize: 24 
    } 
    } 
} 

var ctx = document.getElementById('chartJSContainer').getContext('2d'); 
new Chart(ctx, options); 

這裏你可以看到一個工作示例:

https://jsfiddle.net/fpjzvh4m/

希望這會有所幫助。

P.D:我建議在詢問這類問題時,你包含了一些你的代碼。

相關問題