我正在尝试更改谷歌条形图上所有内容的字体。它适用于除了工具提示之外的所有内容。至少,我认为它被称为工具提示 - 它是您将鼠标悬停在栏上时显示的字体。我觉得我在做它正确根据文档:更改谷歌条形图上的字体
<!doctype html>
<html>
<head>
<style>
@font-face {
font-family: bebas;
src: url(BebasNeue.otf);
}
</style>
</head>
<body>
<h1 style="font-family:bebas;">This font changed</h1>
<script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['bar']}]}"></script>
<div id="cheese_plot" style="width: 900px; height: 500px; font-family:bebas;"></div>
<script type="text/javascript">
google.setOnLoadCallback(drawStuff);
var rawdata = [["Swiss", 90],
["Cheddah", 75],
["'Merican", 35],
["Le bleu", 65],
['Stinky', 70]];
var labels = [['Cheese', 'Pieces']];
var fullArray = labels.concat(rawdata);
function drawStuff() {
var data = new google.visualization.arrayToDataTable(
fullArray
);
var options = {
annotations: {textStyle: { fontName: 'bebas' }},
hAxis: {textStyle: { fontName: 'bebas' }, titleTextStyle: { fontName: 'bebas' }},
vAxis: {textStyle: { fontName: 'bebas' }, titleTextStyle: { fontName: 'bebas' }},
titleTextStyle: { fontName: 'bebas' },
tooltip: {textStyle: {fontName: 'bebas' }},
fontName: 'bebas',
fontSize: 24,
title: 'Cheeseses',
width: 900,
legend: { position: 'none' },
chart: { title: 'Cheese',
subtitle: 'pieces' },
bars: 'horizontal',
axes: {
x: {0: { side: 'top', label: 'Pieces'}}},
bar: { groupWidth: "90%" }
};
var chart = new google.charts.Bar(document.getElementById('cheese_plot'));
chart.draw(data, google.charts.Bar.convertOptions(options));
};
</script>
</body>
</html>
下面是文档:https://developers.google.com/chart/interactive/docs/gallery/barchart?hl=it#data-format
我试图使用自定义字体我从这里得到:http://www.dafont.com/bebas-neue.font
这是谷歌图表错误,我做错了什么;这甚至有可能吗?
这不是很有帮助,但你拼写'芝士'。 – doublesharp
这是故意的。 – wordsforthewise
Then nevermind :) – doublesharp