【问题标题】:How to make/create a population pyramid in echarts?如何在 echarts 中制作/创建人口金字塔?
【发布时间】:2022-11-15 02:13:10
【问题描述】:

我正在尝试使用 echarts (echarts.apache.org) 创建人口金字塔图。我找不到那种例子,也找不到怎么做。图表的值应全部显示为正值。图表示例:https://www.internetgeography.net/wp-content/uploads/2019/12/united-kingdom-population-pyramid-2016.gif

我曾尝试使用带有负数的反向轴条形图,但我找不到将显示的负数转换为正数的方法。

【问题讨论】:

标签: charts echarts


【解决方案1】:

我尝试修改堆栈图并使用负输入值并将显示覆盖为正值 (Math.abs())。

tooltip: {
  trigger: 'axis',
  axisPointer: {
    type: 'shadow'
  },
  valueFormatter: (value) => Math.abs(value)
}
label: {
  show: true,
  position: 'left',
  formatter: function (params) {
    return Math.abs(params.value);
  }
}

Example

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
  • 2021-08-02
  • 2021-12-20
  • 2020-12-16
  • 2014-05-11
  • 1970-01-01
相关资源
最近更新 更多