为什么 RGraph 标签不显示?
Why are RGraph labels not showing?
我有一个使用 RGraph.net 的简单图表模型,我无法弄清楚为什么列的月份标签和轴的 "GBP" 标签没有显示.
我已经把代码放到了https://jsfiddle.net/Abeeee/kcwqn850/32/
var chart = new RGraph.Bar('chart_column', [0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 40, 489, 1011])
.set('zoom.factor', 11)
.set('shadow', true)
.set('labels', ['Jul18', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan19', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'])
.set('shadow.offsetx', 5)
.set('shadow.offsety', 5)
.set('shadow.blur', 9)
.set('gutter.left', 65)
.set('text.font', 'Segoe UI')
.set('colors', ['#FF0000'])
.set('align', 'left')
.set('title.yaxis', 'GBP')
.set('title.yaxis.size', 10)
.set('title.yaxis.x', 7)
.set('title.yaxis.y', 120)
.set('title.yaxis.bold', false)
.set('grid.hoverable', true)
.set('tooltips.effect', 'fade')
.set('tooltips', ['GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 165', 'GBP 40', 'GBP 489', 'GBP 1,011'])
.set('tooltips.event', 'mousemove')
.on('mousemove', function(e, shape) {
e.target.style.cursor = 'pointer';
})
.on('click', function myClick(e, shape) {
var index = shape[5];
alert(labels[index]);
})
.draw();
我想查看图表底部(axis/columns 下方)的月份标签和图表左侧的英镑标签 - 但未显示任何内容。
缺少什么?
谢谢
安倍
您使用的是旧 属性 名称。在第 5 版中,许多都被赋予了新名称。例如标签变为 xaxisLabels。这是您更新的代码:
new RGraph.Bar({
id: 'chart_column',
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 40, 489, 1011],
options: {
shadow: true,
xaxisLabels: ['Jul18', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan19', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
shadowOffsetx: 5,
shadowOffsety: 5,
shadowBlur: 9,
marginLeft: 65,
textFont: 'Segoe UI',
colors: ['red'],
yaxisTitle: 'GBP',
yaxisTitleSize: 10,
yaxisTitleX: 7,
yaxisTitleY: 120,
yaxisTitleBold: false,
tooltipsEffect: 'fade',
tooltips: ['GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 165', 'GBP 40', 'GBP 489', 'GBP 1,011'],
tooltipsEvent: 'mousemove'
}
}).draw().on('mousemove', function (e, shape)
{
e.target.style.cursor = 'pointer';
}).on('click', function (e, shape)
{
var index = shape[5];
alert(labels[index]);
}).draw();
我有一个使用 RGraph.net 的简单图表模型,我无法弄清楚为什么列的月份标签和轴的 "GBP" 标签没有显示.
我已经把代码放到了https://jsfiddle.net/Abeeee/kcwqn850/32/
var chart = new RGraph.Bar('chart_column', [0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 40, 489, 1011])
.set('zoom.factor', 11)
.set('shadow', true)
.set('labels', ['Jul18', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan19', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'])
.set('shadow.offsetx', 5)
.set('shadow.offsety', 5)
.set('shadow.blur', 9)
.set('gutter.left', 65)
.set('text.font', 'Segoe UI')
.set('colors', ['#FF0000'])
.set('align', 'left')
.set('title.yaxis', 'GBP')
.set('title.yaxis.size', 10)
.set('title.yaxis.x', 7)
.set('title.yaxis.y', 120)
.set('title.yaxis.bold', false)
.set('grid.hoverable', true)
.set('tooltips.effect', 'fade')
.set('tooltips', ['GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 165', 'GBP 40', 'GBP 489', 'GBP 1,011'])
.set('tooltips.event', 'mousemove')
.on('mousemove', function(e, shape) {
e.target.style.cursor = 'pointer';
})
.on('click', function myClick(e, shape) {
var index = shape[5];
alert(labels[index]);
})
.draw();
我想查看图表底部(axis/columns 下方)的月份标签和图表左侧的英镑标签 - 但未显示任何内容。
缺少什么?
谢谢 安倍
您使用的是旧 属性 名称。在第 5 版中,许多都被赋予了新名称。例如标签变为 xaxisLabels。这是您更新的代码:
new RGraph.Bar({
id: 'chart_column',
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 40, 489, 1011],
options: {
shadow: true,
xaxisLabels: ['Jul18', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan19', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
shadowOffsetx: 5,
shadowOffsety: 5,
shadowBlur: 9,
marginLeft: 65,
textFont: 'Segoe UI',
colors: ['red'],
yaxisTitle: 'GBP',
yaxisTitleSize: 10,
yaxisTitleX: 7,
yaxisTitleY: 120,
yaxisTitleBold: false,
tooltipsEffect: 'fade',
tooltips: ['GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 0', 'GBP 165', 'GBP 40', 'GBP 489', 'GBP 1,011'],
tooltipsEvent: 'mousemove'
}
}).draw().on('mousemove', function (e, shape)
{
e.target.style.cursor = 'pointer';
}).on('click', function (e, shape)
{
var index = shape[5];
alert(labels[index]);
}).draw();