如何将来自数据库的数据放入图表?

时间:2018-09-15 20:03:47

标签: flutter google-cloud-firestore

我尝试从数据库中显示我的应用程序中的用户活动图表,但它向我显示错误,错误,我的代码在下面。我如何放置值..

List<List<CircularStackEntry>> _quarterlyProfitPieData = [
    <CircularStackEntry>[
      new CircularStackEntry(
        <CircularSegmentEntry>[
          new CircularSegmentEntry(learningScore.toDouble(), Colors.deepPurple, rankKey: 'Q1',),
          new CircularSegmentEntry(1000.0, Colors.amber, rankKey: 'Q2'),
          new CircularSegmentEntry(2000.0, Colors.blue[200], rankKey: 'Q3'),
          new CircularSegmentEntry(1000.0, Colors.red, rankKey: 'Q4'),
          new CircularSegmentEntry(1000.0, Colors.indigo, rankKey: 'Q5'),
          new CircularSegmentEntry(1000.0, Colors.green, rankKey: 'Q6'),
        ],
        rankKey: 'Quarterly Profits',
      ),
    ],

  ];

我的AnimatedCircularChart代码

new AnimatedCircularChart(
                  key: _chartKey,
                  size: _chartSize,
                  initialChartData:_quarterlyProfitPieData[0] ,
                  chartType: CircularChartType.Pie,
                ),

我想要

的看跌期权
 Future<Null> checkScore() async{
    subscription = Firestore.instance.document("users/${widget.profileId}").snapshots().listen((datasnapshot) {

      if (datasnapshot.data.containsKey("learning")) {
        setState(() {
          learningScore = datasnapshot.data["learning"];
        });
      } else if (!datasnapshot.data.containsKey("leaning")) {
        setState(() {
          learningScore = 0;
        });
      }


      if (datasnapshot.data.containsKey("challanger")) {
        setState(() {
          learningScore = datasnapshot.data["challanger"];
        });
      } else if (!datasnapshot.data.containsKey("challanger")) {
        setState(() {
          learningScore = 0;
        });
      }

0 个答案:

没有答案