设置yAxis的最小值和最大值

时间:2019-10-20 16:16:13

标签: react-native mpandroidchart react-native-charts-wrapper

我正在使用MPAndroidChart CombinedChart显示折线图和散点图。 除显示区域尝试适应所有散布数据外,此方法工作正常。这样会将y轴减小到最小y值和最大y值之间的范围。

enter image description here

我不希望这种行为,我需要y轴从0开始到最大140。基本上,我正在尝试实现这种显示方式:

enter image description here

这是我正在使用的代码(React Native和react-native-charts-wrapper)。

查看:

<CombinedChart
            data={this.state.data}
            xAxis={this.state.xAxis}
            onSelect={this.handleSelect.bind(this)}
            onChange={event => console.log(event.nativeEvent)}
            drawOrder={["SCATTER", "LINE"]}
            style={styles.container}
          />

状态:

this.state = {
  xAxis: {
    axisMinimum: 0,
    axisMaximum: 120,
    valueFormatter: ["0", "24", "49", "96", "120"],
    granularityEnabled: true,
    granularity: 1
  },
  yAxis: {
    left: {
      axisMinimum: 0,
      axisMaximum: 140
    }
  },


  data: {
    lineData: {
      dataSets: [
        {
          values: [{ x: 0, y: 75 }, { x: 120, y: 75 }],
          label: "Average Heart Rate",

          config: {
            drawValues: false,
            colors: [processColor("green")],
            drawCircles: false,
            lineWidth: 2,
            axisDependency: "RIGHT"
          }
        }
      ]
    },
    scatterData: {
      dataSets: [
        {
          // "HR_vals"
          values: [
            73.46004999999998,
            73.44,
            70.465,
            71.41,
            71.125,
            70.165,
            72.08,
            74,
            72.54,
            70.53004999999953,
            74.27502500000048,
            74.07995000000001,
            71.74995,
            72.61004999999999,
            72.69995000000003,
            70.159925,
            69.80009999999997,
            73.95007499999998,
            73.33995,
            73.43004999999998,
            75.89004999999999,
            75.079925,
            73.175,
            73.69,
            75.57,
            73.18499999999999,
            72.85000000000004,
            76.765,
            75.13999999999999,
            74.64000000000001,
            78.37519292109832,
            77.31999999999998,
            74.93999999999998,
            74,
            76.685,
            75.28,
            74,
            77.13004335916033,
            75.59995664084406,
            75.27507499999997,
            79.04007499999996,
            77.7298498374172,
            74.31502499999998,
            76.66507499999994,
            76.45995001741362,
            75.02497498102258,
            76.23007499999993,
            78,
            76.93489999999933,
            74.87007500000126,
            77.53002499999995,
            77.23999670142199,
            75.07994999754233,
            76.21507499999989,
            76.74995000000008,
            72.81990000008996,
            71.68507500574655,
            75,
            75,
            75.0400964411845,
            79.26502855881522,
            77.62487500000034,
            73.0649250000002,
            72.03005047679068,
            73.45992452320935,
            71,
            72.03004999999989,
            75.98010006498811,
            77.4099499350118,
            75,
            76.87507499999987,
            76.22990000059855,
            73.41492499934155,
            72.15507499999991,
            75.83007499999994,
            75.36492167958018,
            74.21002832041982,
            76.33507499999997,
            76.67995,
            74.29995000022456,
            74.54000000000002,
            75.06999999999998,
            73.35499999999998,
            74.1150000000001,
            78,
            76.95999999999995,
            75.27495176972536,
            76.97000000000024,
            79.67999999999988,
            76.04999999999987,
            71.7399999999998,
            73.40000000000025,
            74.21999999999987,
            71.89999999999988,
            72.47000000000013,
            76.50000000000013,
            75,
            76.21000000000016,
            80.60000000000076,
            85.53499999999993,
            82.7949999999997,
            75.28999999999922,
            74.33000000000011,
            73.03999999999957,
            70.36499999999988,
            73.46500000000083,
            77,
            76.50499999999987,
            76.72500000000012,
            79.70500000000025,
            78.10999999999972,
            77,
            77.65499999999983,
            75.35999999999969,
            75.08000000000031,
            76.77000000000012,
            74.8699999999995,
            75.18500000000051,
            76.38999999999983,
            76.32000000000073,
            80.70000000000039
          ],
          label: "Company A",

          config: {
            colors: [processColor("purple")],
            drawValues: false,
            scatterShape: "SQUARE"
          }
        } 
      ]
    }
  }
};

0 个答案:

没有答案