简体   繁体   English

作图 Static Y轴值

[英]Compose Chart Static Y-Axis value

Currently I am using Compose Chart of Rechart, and I have two Y-Axis (left and right).目前我正在使用 Rechart 的 Compose Chart,并且我有两个 Y 轴(左和右)。 I was able to make my right y-axis to display 0-100% regardless of the value of bar and line.无论条形和线条的值如何,我都能使我的右 y 轴显示 0-100%。 However, my left y-axis is scaling automatically and it seems domain and tickcounts not working together.但是,我的左 y 轴会自动缩放,并且域和滴答计数似乎不能一起工作。

I need the domain[0, 'datamax'] so that my line is always in 100%, please see my current code.我需要 domain[0, 'datamax'] 以便我的线路始终处于 100%,请查看我当前的代码。

在此处输入图像描述

I wanted that my left and right y-axis to display 0-100%.我希望我的左右 y 轴显示 0-100%。

<ComposedChart
  width={setWidth}
  height={setHeight}
  data={chartData}
  margin={{
    top: 20,
    right: 80,
    bottom: 20,
    left: 20,
  }}
  className={classes.textSize}
>
  <CartesianGrid stroke="#f5f5f5" />
  <XAxis
    dataKey="name"
    scale="band"
    interval={0}
    tick={<CustomizedAxisTick />}
  />
  <YAxis
    yAxisId="left"
    orientation="left"
    label={{
      value: 'Porcentaje',
      angle: -90,
      position: 'insideLeft',
      fill: theme.palette.text.primary,
    }}
    domain={[0, 'datamax']}
    tickCount={11}
    tick={<CustomYAxisTicks />}
  />
  <YAxis
    yAxisId="right"
    orientation="right"
    ticks={ticks}
    tickCount={11}
    tick={{ fill: theme.palette.text.primary }}
  />
  <Bar yAxisId="left" dataKey="pv" barSize={30} fill="#FC6A03" />
  <Line
    yAxisId="left"
    type="monotone"
    dataKey="amt"
    stroke="#eaed40"
    dot={<CustomizedDot />}
    isAnimationActive={false}
  />

I think you have to add an attribute interval={0} in the Yaxis in order to show all values我认为您必须在 Yaxis 中添加一个属性 interval={0} 才能显示所有值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM