Google图表:自定义刻度 [英] Google Charts: Custom Ticks
问题描述
我想在Google图表的水平轴上设置自己的刻度.我尝试包括hAxis.ticks(根据
滴答声
不是材料图表的受支持选项.
材料-> google.charts.Line
- packages:['line']
经典-> google.visualization.LineChart
- packages:['corechart']
您将需要使用经典图表.
注意:经典图表可以选择具有相似外观...
主题:材料"
您可以在此处找到不支持的选项的完整列表...
物料图特征奇偶性跟踪问题
I would like to set my own ticks on the horizontal axis of a Google Chart. I included hAxis.ticks (as per the documentation) in my attempt below, but it refuses to work since the ticks are still not integers even though I specified them to be.
What am I doing wrong?
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['line']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('number', 'Day');
data.addColumn('number', 'myNumber');
data.addRows([
[1,17],
[2,18],
[3,20]
]);
var options = {width: 800, height: 500, hAxis: {ticks: [1,2,3]}};
var chart = new google.charts.Line(document.getElementById('chart'));
chart.draw(data, google.charts.Line.convertOptions(options));
}
</script>
</head>
<body>
<div id="chart"></div>
</body>
</html>
ticks
is not a supported option for material charts.
material --> google.charts.Line
-- packages:['line']
classic --> google.visualization.LineChart
-- packages:['corechart']
you would need to use a classic chart.
note: there is an option for classic charts to have a similar look...
theme: 'material'
you can find the full list of unsupported options here...
Tracking Issue for Material Chart Feature Parity
这篇关于Google图表:自定义刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!