1. 程式人生 > >Highcharts 圖上文字重影問題

Highcharts 圖上文字重影問題

1.圖片上文字出現陰影問題
現象:
這裡寫圖片描述

描述:當背景色設定為深色時就可以看到文字出現重影問題
程式碼:

Highcharts.chart('container', {
    chart: {
        type: 'column',
        backgroundColor: '#434A5C'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    yAxis: {
        stackLabels: {
            style: {
                color: (Highcharts.theme && Highcharts.theme.textColor)||'gray'
, //textOutline:"none" 解決文字重影問題 }, enabled: true } }, plotOptions: { column: { stacking: 'normal', pointPadding: 0, groupPadding: 0, dataLabels: { enabled: false } } }, series: [{ data: [29.9
, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }, { data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2] }] });

點選該文字處,發現程式碼為:

<tspan x="21" y="146" class="highcharts-text-outline"
 fill="#FFFFFF" stroke="#FFFFFF" 
 stroke-width
="2px" stroke-linejoin="round" style="">
173.9</tspan>

發現是 fill=”#FFFFFF” stroke=”#FFFFFF” 屬性造成的

解決方案:
通過嘗試發現 text-shadow沒有任何作用,最後度娘找到解決方案,需要設定
stackLabels.style中 textOutline:”none”

stackLabels是指在柱形圖上方顯示資料的屬性

這裡寫圖片描述