用音符名称标记y轴刻度 [英] Label y-axis ticks with musical note name
本文介绍了用音符名称标记y轴刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图表数据表,其序列值为数字(这些是MIDI音符数字-例如60是中间C,61是Db).
I have a chart data table with series values as numbers (these are MIDI note numbers - e.g. 60 is middle C, 61 is Db).
但是对于用户而言,图表y轴刻度应为注释名称.
But for the user, the chart y-axis ticks should be the note names.
我该怎么办?
推荐答案
使用对象符号,您可以提供值( v:
)和格式化的值( f:
>)每次打勾
using object notation, you can provide the value (v:
) and the formatted value (f:
) for each tick
{v: 60, f: 'C4 (middle C)'}
请参阅以下工作摘要...
see following working snippet...
google.charts.load('current', {
packages: ['corechart']
}).then(function () {
var data = google.visualization.arrayToDataTable([
[1, 60],
[2, 61]
], true);
var options = {
vAxis: {
ticks: [
{v: 60, f: 'C4 (middle C)'},
{v: 61, f: 'C#4/Db4'},
]
}
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
这篇关于用音符名称标记y轴刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文