2011-08-09 79 views
3

有沒有辦法改變hightcharts圖表的字體大小jquery? 我試過了字體大小的選項,但它根本不起作用。更改字體大小jQuery的Hightcharts

我試圖讓圖例字體變小一點,以便它可以適合購物車,如果圖例長的話不需要創建新線。 也許有人曾試過?

這裏是我的腳本:

options = { 

        chart: { 

        backgroundColor: { 

        linearGradient:[0, 0, 500, 500], 

        stops: [ 

         [0, 'rgb(255,255,255)'], 

         [1, 'rgb(237,236, 250)']]}, 

        type: tGraf, 

        renderTo: contGrafik, 

        defaultSeriesType: 'column', 

        width: sWidth 

        }, 

        title: { 

         text: 'Human Resources', 

         style: { 

          font: 'normal 14px Verdana, sans-serif', 

          color : 'black' 

         } 

        }, 

        subtitle: { 

         text: '', 

         style: { 

          font: 'normal 11px Verdana, sans-serif', 

          color : '#000099' 

         } 

        }, 

        xAxis: { 

        title: { 

         text : '' 

        }, 

        labels: { 

         rotation: 0, 

         align: 'right', 

         style: { 

          font: 'normal 11px Verdana, sans-serif', 

          color : 'black' 

         } 

        }, 

        }, 

        yAxis: { 

         allowDecimals : false , 

         labels: { 

         align: 'right', 

          style: { 

           font: 'normal 11px Verdana, sans-serif', 

           color : 'black' 

          } 

         }, 

         gridLineColor: '#EEEFE1', 

         title: { 

          text: 'Employees', 

          style: { 

           font: 'normal 13px Verdana, sans-serif', 

           color : 'black' 

          } 

         } 

        }, 

        plotOptions: { 

        column: { 

         dataLabels : { 

          enabled : true, 

          formatter: function() { 

           return this.y; 

           } 

          }, 

         cursor: 'pointer' 

         }}, 

        legend: { 

         itemWidth : uLegend, 
         style: { 

           font: 'normal 5px Verdana, sans-serif', 

           color : 'black', 

          } 

         symbolPadding: 2, 

         symbolWidth: 15, 

         backgroundColor: '#FFFF99', 

         itemStyle: { 

          cursor: 'pointer', 

          color: '#3E576F' 

         }, 

         width: 600, 

         align: 'center', 

         layout: 'horizontal'}, 

        tooltip: { 

         formatter: function() { 

         return '<b>'+ this.series.name +'</b><br/>'+this.y + ' Orang'; 

         } 

        } 

       }; 

回答

14

你可能會尋找一個傳奇的itemStyle選項:

legend: { 
    itemStyle: { 
     color: '#000000', 
     fontWeight: 'bold', 
     fontSize: '8px' 
    } 
} 
+0

噢,我還沒有嘗試之前:D 現在它工作完美XD – Xinez

0

我相信由Igor給出的答案是好的,但如果你想只需打開highchart.js文件並在其中放置所需的字體樣式即可。只是提供了我在我的情況下所做的修改:

style:{fontFamily:' "Exo 2", sans-serif',fontSize:"12px"},backgroundColor:"#FFFFFF" 

這裏我已將「Lucida」更改爲「Exo 2」。 :)

+0

爲什麼不使用'Highcharts.setOptions({圖:{style:{fontFamily:'...'}}});'? –

+0

我的答案是針對您要更改每個頁面中的高圖表文本的情況。然後,只需在highchart.js文件本身中進行更改。無需其他更改。 –