【问题标题】:set tickValues for y1Axis in linePlusBarChart in ng2-nvd3在 ng2-nvd3 的 linePlusBarChart 中为 y1Axis 设置 tickValues
【发布时间】:2016-10-24 16:35:46
【问题描述】:
this.options = {
      chart: {
          type: 'linePlusBarChart',
          height: 500,
          margin: {
              top: 30,
              right: 75,
              bottom: 50,
              left: 75
          },
          bars: {
              forceY: [0]
          },
          bars2: {
              forceY: [0]
          },
          color: ['#2ca02c', 'darkred'],
          x: function(d, i) { return i; },
          xAxis: {
              axisLabel: 'X Axis',
              tickFormat: (d) => {
                  let dx = this.data[0].values[d] && this.data[0].values[d].x || 0;
                  return dx;
              }
          },
          x2Axis: {
              tickFormat: (d) => {
                  let dx = this.data[0].values[d] && this.data[0].values[d].x || 0;
                  return dx;
              },
              showMaxMin: false
          },
          y1Axis: {
              axisLabel: 'Y1 Axis',
              tickFormat: function(d){
                  return d3.format(',f')(d);
              },
              axisLabelDistance: 12
          },
          y2Axis: {
              axisLabel: 'TargetLine Axis',
              rotateLabels: -35,
          }
      }
    };

我想明确设置y1Axis 范围,例如 1 到 100。我该怎么做?

在 d3 的文档中,我找到了 tickValues 但我不确定如何将此方法用于上述配置对象。

提前感谢您的任何帮助。

【问题讨论】:

    标签: javascript d3.js angular ng2-nvd3


    【解决方案1】:

    找到了答案。如果以后有人需要,仅供参考。

    lines: { 
        // for line chart
        forceY: [0, 100]
    },
    

    无需更改y1Axis,因为它是由行使用的。因此,如果我们只是强制 line 遵循 y 轴的任何准则,它就可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-27
      • 2013-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      相关资源
      最近更新 更多