在Google注释图表上设置轴格式(ScaleFormat选项)
Format axis on Google Annotation Chart (ScaleFormat option)
我有一个谷歌注释图表,显示0到1之间的值,如下所示:jsfiddle
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Kepler-22b mission');
data.addColumn('string', 'Kepler title');
data.addColumn('string', 'Kepler text');
data.addColumn('number', 'Gliese 163 mission');
data.addColumn('string', 'Gliese title');
data.addColumn('string', 'Gliese text');
data.addRows([
[new Date(2314, 2, 15), 0.12400, undefined, undefined,
0.10645, undefined, undefined],
[new Date(2314, 2, 16), 0.24045, 'Lalibertines', 'First encounter',
0.12374, undefined, undefined],
[new Date(2314, 2, 17), 0.35022, 'Lalibertines', 'They are very tall',
0.15766, 'Gallantors', 'First Encounter'],
[new Date(2314, 2, 18), 0.12284, 'Lalibertines', 'Attack on our crew!',
0.34334, 'Gallantors', 'Statement of shared principles'],
[new Date(2314, 2, 19), 0.8476, 'Lalibertines', 'Heavy casualties',
0.66467, 'Gallantors', 'Mysteries revealed'],
[new Date(2314, 2, 20), 0, 'Lalibertines', 'All crew lost',
0.79463, 'Gallantors', 'Omniscience achieved']
]);
var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div'));
var options = {
displayAnnotations: true,
scaleFormat: '#'
};
chart.draw(data, options);
}
默认情况下,纵轴的格式为整数,这对于读取图表来说并不理想。文档有scaleFormat选项(整数默认为"#"),但没有提供任何替代选项。我无法在文档中获得任何其他数字格式选项。
如何将Y轴刻度格式化为小数点后1位的数字?
#
只是一个例子,您可以用任何方式格式化它。对于小数点为1的数字,您需要执行以下操作:
scaleFormat: '#.#'
相关文章:
- 如何使用javascript或html下载PDF格式的填写表单
- 货币代码为欧元-金额的格式不应包含小数
- Json数据包含日期和时间格式
- Javascript日期格式类似于ISO,但本地
- 更改angularjs中的日期-时间格式
- 将日期时间从json转换为可读格式
- NodeJS日期格式不起作用
- 我能得到正确的格式吗
- PHP:显示sqlite数据库中的html格式数据,使用tinymce保存
- 使用正则表达式将输入格式设置为单字符逗号、单字符逗号等
- 将日期和时间转换为UTC格式的日期-Javascript
- Javascript格式UTC日期
- 元素的内容必须由格式正确的字符数据或标记组成
- Datetime格式为Friendly Time.Moment JS输出错误
- 将客户端特定的日期格式返回到服务器MVC4
- 将数字四舍五入到小数点后两位,以设置货币格式
- javascript/jquery将utc转换为短格式的本地时间
- JavaScript生成html格式的密码
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- 在Google注释图表上设置轴格式(ScaleFormat选项)