amcharts4 ColumnSeries固定宽度

问题描述 投票:1回答:1

我正在使用AmCharts4构建甘特图,基于此演示:https://www.amcharts.com/demos/gantt-chart/

它基本上是一个倒置的条形图...我的问题是我在甘特中有很多任务,所以水平条被挤压,我不得不在垂直轴上使用缩放。我希望在垂直轴上有一个固定的条形高度和一个html滚动条,不需要缩放或平移。你有什么主意吗?

enter image description here

谢谢!

amcharts
1个回答
2
投票

我不认为,这可能是普通的amcharts,因为图表是在你提供的区域呈现的。我认为可以根据数据的大小动态设置图表<div>的高度。

图表应该重新渲染以适应新的高度。

const data = [{
    // your data
  }, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

// chart initialisation, etc.

// after setting data
document.getElementById('chart').style.height = `${data.length * 50}px`;
.container {
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
}

#chart {
  width: 100%;
  min-height: 200px;
  background-color: red;
}
<div class="container">
  <div id="chart"></div>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.