Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

去掉右边的Y轴 #68

Closed
gungun0613 opened this issue Aug 14, 2018 · 12 comments
Closed

去掉右边的Y轴 #68

gungun0613 opened this issue Aug 14, 2018 · 12 comments

Comments

@gungun0613
Copy link

例如:https://antv.alipay.com/zh-cn/f2/3.x/demo/other/multiple-y.html
这种双Y轴,如果量级相同,能不能去掉右边的Y轴,根据左边的坐标轴来画图

@simaQ
Copy link
Contributor

simaQ commented Aug 14, 2018

可以,直接:

chart.axis('你要去掉的坐标轴字段名', false);

@gungun0613
Copy link
Author

感觉还是按照右边坐标轴来画,只是把右边的坐标轴文本隐藏掉了

@simaQ
Copy link
Contributor

simaQ commented Aug 14, 2018

恩,这是因为我在 demo 里面,将两个坐标轴的最大值和最小值设置成相同了呢:

你看,两个字段的列定义是一样的:

chart.source(data, {
  tem: {
    min: 0,
    max: 30,
    tickInterval: 10,
    nice: false
  },
  rain: {
    min: 0,
    max: 30,
    tickInterval: 10,
    nice: false
  }
});

@gungun0613
Copy link
Author

我试了,如果把上述这一段去掉,然后加上chart.axis('你要去掉的坐标轴字段名', false);
还是按照右边的坐标轴来显示,数据和左边的坐标轴对不上

@simaQ
Copy link
Contributor

simaQ commented Aug 15, 2018

能截个图说明下你想要的样子么? 或者把你的代码给我看一下,我可能不是特别理解你想要的效果,我根据你的需求帮你调整一下

@gungun0613
Copy link
Author

在没去掉右边坐标轴前图表是这样的
2018-08-15 10 32 13
在去掉右边坐标轴图表是 这样的
2018-08-15 10 33 15
我折线的第一个值是200,可是去掉右边坐标轴,显示的位置不是200,还是原来的位置

@gungun0613
Copy link
Author

不是按照左边的坐标轴来显示数据的

@simaQ
Copy link
Contributor

simaQ commented Aug 15, 2018

恩,我明白了,这是因为柱状图和线图的Y 轴数据范围不同导致的。。。

你把你的原始数据给我下,我帮你调整下

@gungun0613
Copy link
Author

let data = [{
year: '2013',
manage: 100,
netAmount: 200,
name: "经营活动产生现金流"
}, {
year: '2014',
manage: 110,
netAmount: 150,
name: "经营活动产生现金流"
}, {
year: '2015',
manage: 115,
netAmount: 123,
name: "经营活动产生现金流"
}, {
year: '2016',
manage: 230,
netAmount: 250,
name: "经营活动产生现金流"
}, {
year: '2017',
manage: 180,
netAmount: 280,
name: "经营活动产生现金流"
}, {
year: '2018',
manage: 160,
netAmount: 230,
name: "经营活动产生现金流"
}, {
year: '2013',
manage: 200,
netAmount: 200,
name: "投资活动产生现金流"
}, {
year: '2014',
manage: 140,
netAmount: 150,
name: "投资活动产生现金流"
}, {
year: '2015',
manage: 150,
netAmount: 123,
name: "投资活动产生现金流"
}, {
year: '2016',
manage: 230,
netAmount: 250,
name: "投资活动产生现金流"
}, {
year: '2017',
manage: 196,
netAmount: 280,
name: "投资活动产生现金流"
}, {
year: '2018',
manage: 150,
netAmount: 230,
name: "投资活动产生现金流"
}, {
year: '2013',
manage: 200,
netAmount: 200,
name: "筹资活动产生现金流"
}, {
year: '2014',
manage: 370,
netAmount: 150,
name: "筹资活动产生现金流"
}, {
year: '2015',
manage: 400,
netAmount: 123,
name: "筹资活动产生现金流"
}, {
year: '2016',
manage: -450,
netAmount: 250,
name: "筹资活动产生现金流"
}, {
year: '2017',
manage: 260,
netAmount: 280,
name: "筹资活动产生现金流"
}, {
year: '2018',
manage: 140,
netAmount: 230,
name: "筹资活动产生现金流"
}];

@simaQ
Copy link
Contributor

simaQ commented Aug 15, 2018

demo 在这里: https://codepen.io/Sima/pen/djEzME

这是因为两边坐标轴的数值范围不同,层叠柱状图的数据会进行累加,你将右侧 Y 轴的 min 和 max 保持同 左侧的相同即可。

image

如果你的数据是动态的话。你需要手动计算下数据集中的最大值和最小值,如果是静态的话,你看下绘制出来坐标轴的最大和最小值,手动设置下就可以了。

@gungun0613
Copy link
Author

好的,谢谢小姐姐

@StevenGardnerGMJ
Copy link

StevenGardnerGMJ commented Apr 29, 2022

axis

AntV Design Charts中如何像你这样隐藏右侧的Y轴
我试了很多方法 都不行

{
geometry: "line",
seriesField: "type",
smooth: true,
label: {
style: { fill: "#f00" },
},
yAxis:false,
legend: {
marker: {
spacing: 2,
},
},
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants