【问题标题】:How to add padding for column google-charts如何为列 google-charts 添加填充
【发布时间】:2019-04-20 13:51:08
【问题描述】:

我使用带有注释的列 google-chart。对于注释集选项alwaysOutside: true。但是我有一个问题。

我的注释标签自动向下移动到具有最大值的列。

如何解决此问题?

我的图表选项在这里:

const chartOptions = {
  legend: 'none',
  width: 750,
  height: 285,
  bar: { groupWidth: '95%' },
  fontName: 'Open Sans',
  fontSize: 14,
  enableInteractivity: false,
  colors: ['#FF2D55', '#4772D1'],
  vAxis: {
    format: '0',
    baseline: 0,
    viewWindowMode: 'pretty',
    viewWindow: {
      min: 0
    }
  },
  annotations: {
    alwaysOutside: true,
    style: 'point',
    stem: {
      length: 5,
      color: '#FFFFFF'
    },
    textStyle: {
      fontName: 'Open Sans',
      fontSize: 16,
      bold: true,
      color: 'black',
      opacity: 1
    }
  },
  tooltip: {
    trigger: 'none'
  }
};

【问题讨论】:

    标签: google-visualization


    【解决方案1】:

    我自己找到了解决方案。也许有人需要。

    在获得图表的数据后,我发现系列中的最大值并动态设置选项vAxis.minValue。 代码示例:

    const maxValue = this.getMaxValueInSeries(chartSeries);
    this.chartOptions.vAxis.minValue = maxValue + 1;
    

    这对我有用。享受吧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多