use*_*618 4 html jquery svg google-visualization
我希望能够设置由 google 图表 api 创建的仪表图表的字体大小 - https://google-developers.appspot.com/chart/interactive/docs/gallery/gauge
API 中似乎没有选项,所以我希望能够在绘制图表后操作 SVG。我认为这可以通过 jQuery SVG 插件实现 - http://keith-wood.name/svg.html
我对如何使用插件在绘制 SVG 后更新它有点困惑。使用 firebug 我知道绘制图表后 html 看起来像这样。
<iframe>
<html>
<head>...</head>
<body>
<div id="chartArea">
<svg>
<g>
//a couple of circles
<text></text> //The first text element is the title
//the rest of the graph
</g>
</svg>
</div>
</body>
</html>
</iframe>
Run Code Online (Sandbox Code Playgroud)
我希望能够写出这样的东西:
$('#gaugeChartDiv #chartArea').svg('get').change('text:first', { 'font-size' : 8 } );
Run Code Online (Sandbox Code Playgroud)
但似乎并非如此。有人可以提供任何建议吗?
你可以通过CSS来做到这一点:
svg:first-child > g > text[text-anchor~=middle]{
font-size:9px;
}
Run Code Online (Sandbox Code Playgroud)