reactjs - 如何设置堆叠条的最小高度(顶点图,堆叠条)
问题描述
我想在视图中显示一个 ReactApexChart 表,并且我想以一种适合视图的方式设置它。它应该显示对特定主题的答案的统计数据,因此总是只有一条带有正面和负面答案的图表。
但是,我无法使其适合小于 100 像素,对于我没有标题的需求,即使 30 像素也很可能就足够了。
我看到图表上应用了变换,这可能是原因吗?如何让它发挥作用?
这是示例:
{/* <ReactApexChart
options={this.chartOptions}
series={this.chartSeries}
type="bar"
height="100px"
/> */}
这是我的选择和系列
private chartOptions = {
stroke: {
width: 0
},
tooltip: {
show: false
},
chart: {
width: "100%",
stacked: true,
stackType: "100%",
toolbar: {
show: false
}
},
grid: {
show: false
},
plotOptions: {
bar: {
horizontal: true
}
},
xaxis: {
categories: [""],
labels: {
show: false
},
axisBorder: {
show: false
},
crosshairs: {
show: false
}
},
yaxis: {
axisBorder: {
show: false
},
crosshairs: {
show: false
}
},
legend: {
show: false
},
fill: {
opacity: 1
}
};
private chartSeries = [
{
name: "Empty",
data: [44]
},
{
name: "Success",
data: [5]
},
{
name: "Error",
data: [1]
}
];
解决方案
你能写一个函数来设置那个图表的高度吗?所以在我的一个图表中,我必须修复大小,以便页面不显示任何滚动。我的图表选项就像
chart: {
height: yourFunctionForHeight(), //return only number
type: 'bar',
stacked: true,
toolbar: {
show: true
}
}
function yourHeightFunction() {
//logic that calculates height
return number; //without attaching px to it
}
推荐阅读
- python-3.x - 如何在python中按点标签一一添加颜色和图例?
- google-sheets - 如何根据另一个工作表更新 Google 工作表中的数据?
- java - 如何拆分值并保存到 Map java?
- google-maps - 似乎无法向我的地图添加额外的 GLTF 标记(WebGL)
- python - MPI (mpi4py) - 如果第一个 test() 返回 false,则 irecv() 和 test() 不会在循环中工作
- excel - 如何避免 CSV 文件在使用 text-to-column 功能时将某些行更改为日期格式?
- javascript - JavaScript 排名排行榜
- ios - iOS推送通知声音停止使用天蓝色通知中心工作[根本没有声音]
- solr - 如何将 solr 中的日期格式从 yyyy-mm-ddThh:mm:ssZ 更改为“dd/MM/yyyy”?
- tailwind-css - 自动拉伸顺风体以适应其他div