0

我正在使用fl_chart库来绘制折线图。到目前为止我所做的是,

return LineChartData(
  gridData: FlGridData(
    show: false,
    drawVerticalLine: false,
    getDrawingHorizontalLine: (value) {
      return FlLine(
        strokeWidth: 0,
      );
    },
    getDrawingVerticalLine: (value) {
      return FlLine(
        strokeWidth: 0,
      );
    },
  ),
  titlesData: FlTitlesData(
    show: true,
    rightTitles: SideTitles(
      showTitles: true,
      interval: 3,
      rotateAngle: 330,
      getTextStyles: (context, value) => const TextStyle(
        color: Color(0xffffffff),
        fontWeight: FontWeight.w400,
        fontSize: 10,
      ),
      getTitles: (value) {
        return yAxis[value.toInt()];
      },
      reservedSize: 30,
      margin: 5,
    ),
    topTitles: SideTitles(showTitles: false),
    bottomTitles: SideTitles(
      showTitles: true,
      reservedSize: 18,
      rotateAngle: 320,
      interval: 3,
      getTextStyles: (context, value) => const TextStyle(
          color: Color(0xffffffff),
          fontWeight: FontWeight.w400,
          fontSize: 10),
      getTitles: (value) {
        print("xAxis values $value - ${xAxis[value.toInt()]}");
        return xAxis[value.toInt()];
      },
      margin: 8,
    ),
    leftTitles: SideTitles(showTitles: false),
  ),
  borderData: FlBorderData(
      show: true,
      border: Border.all(color: const Color(0xFFFFFFFF), width: 1)),
  minX: 0,
  minY: 0,
  lineBarsData: [
    LineChartBarData(
      spots: const[
        FlSpot(1, 10.50),
        FlSpot(2, 11.50),
        FlSpot(3, 9.50),
        FlSpot(4, 13.50),
        FlSpot(5, 14.50),
        FlSpot(6, 15.50),
        FlSpot(7, 16.50),
        FlSpot(8, 15.50),
        FlSpot(9, 12.50),
        FlSpot(10, 10.50),

      ],
      isCurved: true,
      colors: gradientColors,
      barWidth: 2,
      isStrokeCapRound: true,
      dotData: FlDotData(
        show: false,
      ),
      belowBarData: BarAreaData(
        show: false,
      ),
    ),
  ],
);

这是我的回应:

{
"Status": "pass",
"Message": "Operation completed successfully",
"series": [
    {
        "data": [
            [
                1578873600000,
                0.0
            ],
            [
                1578960000000,
                0.0
            ],
            [
                1579046400000,
                0.0
            ],
            [
                1579132800000,
                0.0
            ],
            [
                1579219200000,
                0.0
            ],
            [
                1579478400000,
                0.0
            ],
            [
                1579564800000,
                0.0
            ],
            [
                1579651200000,
                0.0
            ],
            [
                1579737600000,
                0.0
            ],
            [
                1579824000000,
                0.0
            ],
            [
                1580083200000,
                0.0
            ],
            [
                1580169600000,
                0.0
            ],
            [
                1580256000000,
                0.0
            ],
            [
                1580342400000,
                0.0
            ],
            [
                1580428800000,
                0.0
            ],
            [
                1580688000000,
                1000.0
            ],
            [
                1580774400000,
                1000.0
            ],
            [
                1580860800000,
                1000.0
            ],
            [
                1580947200000,
                1000.0
            ],
            [
                1581033600000,
                1000.0
            ],
            [
                1581292800000,
                1000.0
            ],
            [
                1581379200000,
                1000.0
            ],
            [
                1581465600000,
                1000.0
            ],
            [
                1581552000000,
                1000.0
            ],
            [
                1581638400000,
                1000.0
            ],
            [
                1581897600000,
                1000.0
            ],
            [
                1581984000000,
                1000.0
            ],
            [
                1582070400000,
                1000.0
            ],
            [
                1582156800000,
                1000.0
            ],
            [
                1582243200000,
                1000.0
            ],
            [
                1582502400000,
                1000.0
            ],
            [
                1582588800000,
                1000.0
            ],
            [
                1582675200000,
                1000.0
            ],
            [
                1582761600000,
                1000.0
            ],
            [
                1582848000000,
                1000.0
            ],
            [
                1583107200000,
                2000.0
            ],
            [
                1583193600000,
                2000.0
            ],
            [
                1583280000000,
                2000.0
            ],
            [
                1583366400000,
                2000.0
            ],
            [
                1583452800000,
                2000.0
            ],
            [
                1583712000000,
                2000.0
            ],
            [
                1583798400000,
                2000.0
            ],
            [
                1583884800000,
                2000.0
            ],
            [
                1583971200000,
                2000.0
            ],
            [
                1584057600000,
                2000.0
            ],
            [
                1584316800000,
                2000.0
            ],
            [
                1584403200000,
                2000.0
            ],
            [
                1584489600000,
                2000.0
            ],
            [
                1584576000000,
                2000.0
            ],
            [
                1584662400000,
                2000.0
            ],
            [
                1584921600000,
                2000.0
            ],
            [
                1585008000000,
                2000.0
            ],
            [
                1585094400000,
                2000.0
            ],
            [
                1585180800000,
                2000.0
            ],
            [
                1585267200000,
                2000.0
            ],
            [
                1585526400000,
                2000.0
            ],
            [
                1585612800000,
                2000.0
            ],
            [
                1585699200000,
                3000.0
            ],
            [
                1585785600000,
                3000.0
            ],
            [
                1585872000000,
                3000.0
            ],
            [
                1586131200000,
                3000.0
            ],
            [
                1586217600000,
                3000.0
            ],
            [
                1586304000000,
                3000.0
            ],
            [
                1586390400000,
                3000.0
            ],
            [
                1586476800000,
                3000.0
            ],
            [
                1586736000000,
                3000.0
            ],
            [
                1586822400000,
                3000.0
            ],
            [
                1586908800000,
                3000.0
            ],
            [
                1586995200000,
                3000.0
            ],
            [
                1587081600000,
                3000.0
            ],
            [
                1587340800000,
                3000.0
            ],
            [
                1587427200000,
                3000.0
            ],
            [
                1587513600000,
                3000.0
            ],
            [
                1587600000000,
                3000.0
            ],
            [
                1587686400000,
                3000.0
            ],
            [
                1587945600000,
                3000.0
            ],
            [
                1588032000000,
                3000.0
            ],
            [
                1588118400000,
                3000.0
            ],
            [
                1588204800000,
                3000.0
            ],
            [
                1588291200000,
                4000.0
            ],
            [
                1588550400000,
                4000.0
            ],
            [
                1588636800000,
                4000.0
            ],
            [
                1588723200000,
                4000.0
            ],
            [
                1588809600000,
                4000.0
            ],
            [
                1588896000000,
                4000.0
            ],
            [
                1589155200000,
                4000.0
            ],
            [
                1589241600000,
                4000.0
            ],
            [
                1589328000000,
                4000.0
            ],
            [
                1589414400000,
                4000.0
            ],
            [
                1589500800000,
                4000.0
            ],
            [
                1589760000000,
                4000.0
            ],
            [
                1589846400000,
                4000.0
            ],
            [
                1589932800000,
                4000.0
            ],
            [
                1590019200000,
                4000.0
            ],
            [
                1590105600000,
                4000.0
            ],
            [
                1590364800000,
                4000.0
            ],
            [
                1590451200000,
                4000.0
            ],
            [
                1590537600000,
                4000.0
            ],
            [
                1590624000000,
                4000.0
            ],
            [
                1590710400000,
                4000.0
            ],
            [
                1590969600000,
                5000.0
            ],
            [
                1591056000000,
                5000.0
            ],
            [
                1591142400000,
                5000.0
            ],
            [
                1591228800000,
                5000.0
            ],
            [
                1591315200000,
                5000.0
            ],
            [
                1591574400000,
                5000.0
            ],
            [
                1591660800000,
                5000.0
            ],
            [
                1591747200000,
                5000.0
            ],
            [
                1591833600000,
                5000.0
            ],
            [
                1591920000000,
                5000.0
            ],
            [
                1592179200000,
                5000.0
            ],
            [
                1592265600000,
                5000.0
            ],
            [
                1592352000000,
                5000.0
            ],
            [
                1592438400000,
                5000.0
            ],
            [
                1592524800000,
                5000.0
            ],
            [
                1592784000000,
                5000.0
            ],
            [
                1592870400000,
                5000.0
            ],
            [
                1592956800000,
                5000.0
            ],
            [
                1593043200000,
                5000.0
            ],
            [
                1593129600000,
                5000.0
            ],
            [
                1593388800000,
                5000.0
            ],
            [
                1593475200000,
                5000.0
            ],
            [
                1593561600000,
                6000.0
            ],
            [
                1593648000000,
                6000.0
            ],
            [
                1593734400000,
                6000.0
            ],
            [
                1593993600000,
                6000.0
            ],
            [
                1594080000000,
                6000.0
            ],
            [
                1594166400000,
                6000.0
            ],
            [
                1594252800000,
                6000.0
            ],
            [
                1594339200000,
                6000.0
            ],
            [
                1594598400000,
                6000.0
            ],
            [
                1594684800000,
                6000.0
            ],
            [
                1594771200000,
                6000.0
            ],
            [
                1594857600000,
                6000.0
            ],
            [
                1594944000000,
                6000.0
            ],
            [
                1595203200000,
                6000.0
            ],
            [
                1595289600000,
                6000.0
            ],
            [
                1595376000000,
                6000.0
            ],
            [
                1595462400000,
                6000.0
            ],
            [
                1595548800000,
                6000.0
            ],
            [
                1595808000000,
                6000.0
            ],
            [
                1595894400000,
                6000.0
            ],
            [
                1595980800000,
                6000.0
            ],
            [
                1596067200000,
                6000.0
            ],
            [
                1596153600000,
                6000.0
            ],
            [
                1596412800000,
                7000.0
            ],
            [
                1596499200000,
                7000.0
            ],
            [
                1596585600000,
                7000.0
            ],
            [
                1596672000000,
                7000.0
            ],
            [
                1596758400000,
                7000.0
            ],
            [
                1597017600000,
                7000.0
            ],
            [
                1597104000000,
                7000.0
            ],
            [
                1597190400000,
                7000.0
            ],
            [
                1597276800000,
                7000.0
            ],
            [
                1597363200000,
                7000.0
            ],
            [
                1597622400000,
                7000.0
            ],
            [
                1597708800000,
                7000.0
            ],
            [
                1597795200000,
                7000.0
            ],
            [
                1597881600000,
                7000.0
            ],
            [
                1597968000000,
                7000.0
            ],
            [
                1598227200000,
                7000.0
            ],
            [
                1598313600000,
                7000.0
            ],
            [
                1598400000000,
                7000.0
            ],
            [
                1598486400000,
                7000.0
            ],
            [
                1598572800000,
                7000.0
            ],
            [
                1598832000000,
                7000.0
            ],
            [
                1598918400000,
                8000.0
            ],
            [
                1599004800000,
                8000.0
            ],
            [
                1599091200000,
                8000.0
            ],
            [
                1599177600000,
                8000.0
            ],
            [
                1599436800000,
                8000.0
            ],
            [
                1599523200000,
                8000.0
            ],
            [
                1599609600000,
                8000.0
            ],
            [
                1599696000000,
                8000.0
            ],
            [
                1599782400000,
                8000.0
            ],
            [
                1600041600000,
                8000.0
            ],
            [
                1600128000000,
                8000.0
            ],
            [
                1600214400000,
                8000.0
            ],
            [
                1600300800000,
                8000.0
            ],
            [
                1600387200000,
                8000.0
            ],
            [
                1600646400000,
                8000.0
            ],
            [
                1600732800000,
                8000.0
            ],
            [
                1600819200000,
                8000.0
            ],
            [
                1600905600000,
                8000.0
            ],
            [
                1600992000000,
                8000.0
            ],
            [
                1601251200000,
                8000.0
            ],
            [
                1601337600000,
                8000.0
            ],
            [
                1601424000000,
                8000.0
            ],
            [
                1601510400000,
                9000.0
            ],
            [
                1601596800000,
                9000.0
            ],
            [
                1601856000000,
                9000.0
            ],
            [
                1601942400000,
                9000.0
            ],
            [
                1602028800000,
                9000.0
            ],
            [
                1602115200000,
                9000.0
            ],
            [
                1602201600000,
                9000.0
            ],
            [
                1602460800000,
                9000.0
            ],
            [
                1602547200000,
                9000.0
            ],
            [
                1602633600000,
                9000.0
            ],
            [
                1602720000000,
                9000.0
            ],
            [
                1602806400000,
                9000.0
            ],
            [
                1602892800000,
                9000.0
            ],
            [
                1602979200000,
                9000.0
            ],
            [
                1603065600000,
                9000.0
            ],
            [
                1603152000000,
                9000.0
            ],
            [
                1603238400000,
                9000.0
            ],
            [
                1603324800000,
                9000.0
            ],
            [
                1603411200000,
                9000.0
            ],
            [
                1603670400000,
                9000.0
            ],
            [
                1603756800000,
                9000.0
            ],
            [
                1603843200000,
                9000.0
            ]
        ],
        "name": "Invested Monthly SIP",
        "type": "line"
    }

] }

从上面的响应整数值是时间戳,我希望以“yy-MMM”格式显示 x 轴。

我在用响应绘制 FlSpots 时遇到问题。我尝试使用正确绘制的硬代码值。现在我想将响应值设置为 FlSpot。flSpot 仅接受双精度值。

4

0 回答 0