我正在为列和数据1,数据2生成动态名称。现在,我尝试在条形图中显示Y
和Y2
但在y2
轴中仅显示0
js
1
到c3
值
$(document).ready(function () {
var FunnelGrowthACVColumns = [];
var FunnelGrowthRatioColumns = [];
for (var i = 0; i <= data.data.FunnelGrowthMartix.length - 1; i++) {
FunnelGrowthACVColumns.push(parseFloat(data.data.FunnelGrowthMartix[i].FunnelGrowth));
FunnelGrowthRatioColumns.push(parseFloat(data.data.FunnelGrowthMartix[i].Per_Growth));
}
var titleFunnelGrowthACV = data.data.FunnelGrowthMartix[0].Title + 'ACV';
var titleFunnelGrowthRatio = data.data.FunnelGrowthMartix[0].Title +'Ratio';
var chart1 = c3.generate({
bindto: '#chartContainer2',
data: {
columns: [
[titleFunnelGrowthACV].concat(FunnelGrowthACVColumns),
[titleFunnelGrowthRatio].concat(FunnelGrowthRatioColumns),
],
type: 'bar',
labels: true,
axes: {
titleFunnelGrowthACV: 'y',
titleFunnelGrowthRatio: 'y2'
},
},
axis: {
x: {
type: 'category',
categories: MartixMonths,
},
y: {
label: {
text: 'Unit (In Rs Crores)',
position: 'outer-middle'
},
},
y2: {
show: true,
}
},
color: {
pattern: ['#2ca02c', '#0000ff']
},
zoom: {
enabled: false
},
bar: {
width: {
ratio: 0.5
},
tooltip: {
format: {
title: function (d) { return 'Data' + d; },
},
grouped: true
},
legend: {
position: 'center'
}
}
});
$('#chartContainer2').append(chart1.element);
});
数据1和数据2的y轴值都在变化。
答案 0 :(得分:0)
第二个y轴的范围0..1往往在一个系列尚未绑定时发生。
查看截图我怀疑你刚收到错字。屏幕截图中的工具提示显示系列名称“FunnelGrowthACV”和“FunnelGrowthRatio”,但您要求
axes: {
titleFunnelGrowthACV: 'y',
titleFunnelGrowthRatio: 'y2'
},
将其更改为
axes: {
FunnelGrowthACV: 'y',
FunnelGrowthRatio: 'y2'
},
并查看现在是否有效