2012-02-06 43 views
2

正如你可以看到我試圖設置字體家庭,我已經在文件中提到的各種方式嘗試過:http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html谷歌的可視化圖表即FONT-FAMILY不尊重

但ie7-8( vml版本)顯示錯誤的字體。這可能是一個VML問題,而不是一個谷歌的問題,但我的想法。謝謝你們!

// Load the Visualization API and the piechart package. 
    google.load('visualization', '1.0', {'packages':['corechart']}); 

    // Set a callback to run when the Google Visualization API is loaded. 
    google.setOnLoadCallback(drawChart); 

    // Callback that creates and populates a data table, 
    // instantiates the pie chart, passes in the data and 
    // draws it. 
    function drawChart() { 

    // Create the data table. 
    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'Vote'); 
    data.addColumn('number', 'Votes'); 
    data.addRows([ 
    ['BLAH', blah], 
    ['AHH', ahh] 
    ]); 

    // Set chart options 
    var options = { 
     is3D:false, 
     width:200, 
     height:200, 
     fontSize: '14px', 
     fontName: 'Arial', 
     colors: ['#bcbdc0', '#FFF'], 
     legend: 'none', 
     pieSliceText: 'label', 
     backgroundColor: '#f8f6e8' , 
     pieSliceBorderColor: 'black', 
     pieSliceTextStyle: { 
      color: 'black', fontName: 'Arial', fontSize:'14' 
     } 

    }; 

    // Instantiate and draw our chart, passing in some options. 
    var chart = new google.visualization.PieChart(document.getElementById('chart-div-'+id)); 
    chart.draw(data, options); 
    } 

回答

9

嘗試改用:

fontName: '"Arial"' 

即,單引號內添加額外的雙引號。這工作對我來說(但看起來還是醜陋使用的字體是宋體加粗,但所有元素的尺寸似乎用標準的宋體導致在所有詞的結尾丟失的像素設置)

+0

我居然做到了。 – Fresheyeball 2012-03-02 01:27:11