Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to add another line in the time series chart. And currently I did not find anyway to do this. I am using chart_flutter dependencies.

Here is my chart code look like:

charts.TimeSeriesChart(
                  series,
                  animate: true,
                  defaultRenderer: charts.LineRendererConfig(
                    includeArea: true,
                    includeLine: true,
                  ),
                  dateTimeFactory: const charts.LocalDateTimeFactory(),
                  behaviors: [
                    charts.PanAndZoomBehavior(),
                    charts.SeriesLegend(
                      position: charts.BehaviorPosition.top,
                      horizontalFirst: false,
                      cellPadding: EdgeInsets.only(left: 80, top: 10, bottom: 4.0),
                    ),
                    charts.SelectNearest(
                      eventTrigger: charts.SelectionTrigger.tap
                    ),
                    charts.LinePointHighlighter(
                      symbolRenderer: CustomCircleSymbolRenderer(size: size),
                    ),
                  ],
                  selectionModels: [
                    charts.SelectionModelConfig(
                    type: charts.SelectionModelType.info,
                    changedListener: (charts.SelectionModel model) {
                      if(model.hasDatumSelection) {
                        final tankVolumeValue = model.selectedSeries[0].measureFn(model.selectedDatum[0].index).round();
                        final dateValue = model.selectedSeries[0].domainFn(model.selectedDatum[0].index);
                        CustomCircleSymbolRenderer.value = '$dateValue 
 $tankVolumeValue';
                    }
                  })
                ]),

Any idea on how to add another line is welcome.

question from:https://stackoverflow.com/questions/65660927/how-to-add-many-line-in-time-series-chart-in-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
151 views
Welcome To Ask or Share your Answers For Others

1 Answer

The answer above is simply that you can add more data in the variable that hold the data. Like below:

charts.Series(
          id: 'Tank 1',
          data: some data here,
          colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
          domainFn: (TankPing ping, _) => some data,
          measureFn: (TankPing ping, _) => some data
        ),
charts.Series(
              id: 'Tank 1',
              data: some data here,
              colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
              domainFn: (TankPing ping, _) => some data,
              measureFn: (TankPing ping, _) => some data
            )

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...