我尝试将格式化程序应用于数据表列但忽略它。
function drawMultSeries(orderData) {
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('string', Translator.trans('company.dashboard.order_chart.days'));
dataTable.addColumn('number', Translator.trans('company.dashboard.orders_title'));
dataTable.addColumn('number', Translator.trans('company.dashboard.order_chart.expenses'));
dataTable.addRows(orderData);
var formatter = new google.visualization.NumberFormat(
{prefix: 'test'});
formatter.format(dataTable, 2);
var options = {
allowHtml: true,
title: Translator.trans('company.dashboard.orders_title'),
hAxis: {
title: Translator.trans('company.dashboard.order_chart.days'),
viewWindow: {
min: [7, 30, 0],
max: [17, 30, 0]
}
},
vAxes: {
1: { format: 'currency' }
},
colors: ['#8fd5ba', '#1C2C3A'],
series: {
0: { type: 'bars', targetAxisIndex: 0 },
1: { type: 'area', targetAxisIndex: 1, areaOpacity: 0.07 }
}
};
var chart = new google.visualization.ComboChart(
document.getElementById('chart-orders'));
$('.dashboard-chart-loading').hide();
$('#chart-orders').show();
chart.draw(dataTable, options);
}
我希望右侧的Axis有"测试"字符串前缀为任何值。
答案 0 :(得分:0)
您正在格式化数据,将鼠标悬停在折线图上的某个数据点上,您将看到测试。
格式化轴...
vAxes: {
1: { format: 'test $#,##0.00' }
},
示例...
google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawMultSeries);
function drawMultSeries() {
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('string', 'days');
dataTable.addColumn('number', 'title');
dataTable.addColumn('number', 'expenses');
dataTable.addRows([
['18/09', 1, 160],
['22/09', 1, 250]
]);
var formatter = new google.visualization.NumberFormat(
{prefix: 'test'});
formatter.format(dataTable, 2);
var options = {
allowHtml: true,
title: 'title',
hAxis: {
title: 'days',
viewWindow: {
min: [7, 30, 0],
max: [17, 30, 0]
},
},
vAxes: {
1: { format: 'test $#,##0.00' }
},
colors: ['#8fd5ba', '#1C2C3A'],
series: {
0: { type: 'bars', targetAxisIndex: 0 },
1: { type: 'area', targetAxisIndex: 1, areaOpacity: 0.07 }
}
};
var chart = new google.visualization.ComboChart(
document.getElementById('chart-orders')
);
chart.draw(dataTable, options);
}

<script src="https://www.google.com/jsapi"></script>
<div id="chart-orders"></div>
&#13;