nvd3 + lineplusbarchart +外来轴 [英] nvd3 + lineplusbarchart + allign axises

查看:99
本文介绍了nvd3 + lineplusbarchart +外来轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定我是否要按照正确的方式进行操作,但是可以解决...

not sure if I am going about this the right way but here goes...

因此,我有以下示例在此处查看小提琴 使用lineplusbarchart,我在这里发布的这个问题上建立了它: SO问题

So i have the this example see fiddle here using lineplusbarchart and i am building on it from this question i posted here: SO question

我已经编辑了lineplusbarchart以在x轴上显示标签:

I have edited the lineplusbarchart to show the labels on the xaxis:

    chart.xAxis.tickFormat(function(d) {
  var dx = testdata[0].values[d] && testdata[0].values[d].x || 0;
          return dx;
      })
      .showMaxMin(false);

但是我仍然有一些问题要得到我想要的...

but i am still having a couple of issues to get what i want...

1->
如何设置y1和y2轴? (理想情况下,如果只有一个轴,那会很好)
2->
如何删除y2轴? (此处的外观,但是这不起作用,因为我当时想要2轴对齐)
3->
如何使label1和label5的条形图部分的厚度与其他(lable2,3和4)的厚度相同?

1 ->
how can i make the y1 and y2 axis be alligned? (ideally it would be good if there was only one axis)
2 ->
how do i remove the y2 axis? (soution here but this does not work as I then want the 2 axis aligned)
3 ->
how do i make the thickness of the barchart part for label1 and label5 to be the same thickness as the others(lable2,3 and 4)?

推荐答案

希望有帮助:

  1. ,您可以使用chart.lines.forceY()设置范围.为了做到这一点 我建议使用动态值来查找附加数据的整体最大值 并将其用于条形和线条.例如:

  1. you can use chart.lines.forceY() to set a range. To make it work with dynamic values I'd suggest to find the overall max value of the attached data and use it for the bar and the lines. Eg:

var maxValue = d3.max(d3.entries(testdata), function(d) {
        return d3.max(d3.entries(d.value.values), function(e) {
            return e.value.y;
        });
    }),
    minValue = 0;

chart.bars.forceY([minValue, maxValue]);
chart.lines.forceY([minValue, maxValue]);

  • 您发布的解决方案正是我要做的.
  • 删除padData()
  • Your posted solution is exactly what I would do too.
  • Remove padData()
  • 这篇关于nvd3 + lineplusbarchart +外来轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆