【问题标题】:Recharts get rid of inner margin/spacing of area to top of chartRecharts 摆脱了图表顶部的内部边距/区域间距
【发布时间】:2023-02-03 19:17:17
【问题描述】:

我有以下图表,我想在其中摆脱购物车顶部的区域空间 - 我希望图表以该区域垂直结束:

const data = [{ y: 0 }, { y: 60 }, { y: 50 }, { y: 50 }, { y: 120 }, { y: 30 }, { y: 0 }];

<ResponsiveContainer width="100%" height="100%">
    <AreaChart data={data} margin={{ top: 0, left: 0, bottom: 0, right: 0 }}>
        <Area
            dataKey="y"
            type="basis"
            stroke={colors.lime400}
            fill={colors.lime400}
            fillOpacity={0.3}
            isAnimationActive={false}
        />
        <CartesianGrid stroke={colors.gray300} horizontal={false} />
    </AreaChart>
</ResponsiveContainer>

【问题讨论】:

    标签: javascript typescript recharts


    【解决方案1】:

    您可以使用

    <YAxis type="number" domain={[0, 'dataMax']} />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-07
      • 2016-11-29
      • 2012-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多