更改图表中的字体颜色

时间:2014-05-28 23:25:21

标签: php html google-visualization

我已经尝试使用Google Charts API三小时来更改下面显示的下一个颜色。正如你所看到的,我已经用白色绘制了X / Y轴,但这就是我所能做的所有事情,虽然改变了背景颜色。

enter image description here

我一直在阅读此处的文档:https://developers.google.com/chart/interactive/docs/gallery/table

3 个答案:

答案 0 :(得分:3)

图表中的许多标签都有textStyle个关联选项。在您的情况下,您希望使用hAxis.textStylevAxis.textStylelegend.textStyletitleTextStyle

hAxis: {
    textStyle: {
        color: '#ffffff'
    }
},
vAxis: {
    textStyle: {
        color: '#ffffff'
    }
},
legend: {
    textStyle: {
        color: '#ffffff'
    }
},
titleTextStyle: {
    color: '#ffffff'
}

答案 1 :(得分:1)

legend.textStyle和tooltip.textStyle控制此项,如实例here

的散点图所示

答案 2 :(得分:0)

我想,我已经了解了谷歌图表的主要属性。 他们

// options
var options = {
// title
title: 'What is your favourite season?',
titleTextStyle: {color: '#006633'},
// horizontal axis
hAxis: { 
textStyle: {
color: '#ffffff',
fontName: 'Tahoma',
fontSize: 12},
slantedText: false,
minTextSpacing: 1,
},
// vertical axis
vAxis: { 
textStyle: {
color: '#ffffff',
fontName: 'Tahoma',
fontSize: 12},
slantedText: false,
minTextSpacing: 1,
},
// legend
legend: {
textStyle: {
color: '#c7d781',
fontSize:14,
bold:true,
italic:false
}
},
// tooltip
tooltip: {
textStyle: {
color: '#ff0000',
fontSize:14,
bold:true,
italic:false
}
},
// chart
width:740,
height:200,
backgroundColor: 'transparent',
baselineColor: 'white'
};
var chart = new google.visualization.ColumnChart(document.getElementById('chartContainer-03'));
chart.draw(data, options);
}

源代码和演示here

相关问题