在柱形图中设置最小和最大 Y 轴
Set Min & Max Yaxis in the column chart
我遇到以下问题:
我需要为图表设置最小值和最大值。
我试过 Scale,但它不起作用。
function drawChart1() {
// Define the chart to be drawn.
var data = google.visualization.arrayToDataTable([
['Year', 'Actual', { role: 'annotation' }, 'Target', { role: 'annotation' }],
['2017', 1, '1', 0, '0'],
['2018', 1, '1', 0, '0'],
['2019', 0, '0', 0, '0'],
['2020', 0, '0', 0, '0'],
['2021', 0, '0', 0, '0'],
//['2018', 0.0, '0.0', 0.025, '0.025']
]);
// title: '%' // in opption
var options = {
title: '', colors: ['#00A3E0', '#84BD00'],
};
// Instantiate and draw the chart.
var chart = new google.visualization.ColumnChart(document.getElementById('container1'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart1);
使用以下 vAxis
选项...
var options = {
title: '',
colors: ['#00A3E0', '#84BD00'],
// use following options...
vAxis: {
viewWindow: {
min: 0,
max: 1
}
}
};
我遇到以下问题:
我需要为图表设置最小值和最大值。
我试过 Scale,但它不起作用。
function drawChart1() {
// Define the chart to be drawn.
var data = google.visualization.arrayToDataTable([
['Year', 'Actual', { role: 'annotation' }, 'Target', { role: 'annotation' }],
['2017', 1, '1', 0, '0'],
['2018', 1, '1', 0, '0'],
['2019', 0, '0', 0, '0'],
['2020', 0, '0', 0, '0'],
['2021', 0, '0', 0, '0'],
//['2018', 0.0, '0.0', 0.025, '0.025']
]);
// title: '%' // in opption
var options = {
title: '', colors: ['#00A3E0', '#84BD00'],
};
// Instantiate and draw the chart.
var chart = new google.visualization.ColumnChart(document.getElementById('container1'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart1);
使用以下 vAxis
选项...
var options = {
title: '',
colors: ['#00A3E0', '#84BD00'],
// use following options...
vAxis: {
viewWindow: {
min: 0,
max: 1
}
}
};