2012-02-06 73 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