【问题标题】:Candlesticks with syncfusion in flutter颤动中带有同步融合的烛台
【发布时间】:2020-11-27 08:12:52
【问题描述】:

我正在尝试使用syncfusion 并尝试获得像documentation 中所示的烛台图。不幸的是,当我尝试我的代码而不是看到蜡烛时,看到一条水平绿线,我不明白为什么。我使用了以下代码:

图表数据

class ChartData {
  double x;
  double open;
  double high;
  double low;
  double close;

  ChartData({this.x, this.open, this.high, this.low, this.close});
}

我的有状态小部件中的构建方法

@override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(),
      body: SafeArea(
        child: Row(
          children: [
            Expanded(
              child: ListView(
                physics: BouncingScrollPhysics(),
                scrollDirection: Axis.horizontal,
                children: <Widget>[
                  Padding(
                      padding: const EdgeInsets.all(20.0),
                      child: Container(
                        width: MediaQuery.of(context).size.width * 3,
                        child: SfCartesianChart(
                            title: ChartTitle(text: "Candlesticks"),
                            primaryXAxis: NumericAxis(),
                            series: <ChartSeries>[
                              CandleSeries<ChartData, double>(
                                showIndicationForSameValues: true,
                                dataSource: <ChartData>[
                                  ChartData(
                                      // Open and close values are same
                                      x: 5,
                                      open: 86.3593,
                                      high: 88.1435,
                                      low: 84.3914,
                                      close: 86.3593),
                                ],
                                xValueMapper: (ChartData data, _) => data.x,
                                highValueMapper: (ChartData data, _) =>
                                    data.high,
                                lowValueMapper: (ChartData data, _) => data.low,
                                openValueMapper: (ChartData data, _) =>
                                    data.open,
                                closeValueMapper: (ChartData data, _) =>
                                    data.close,
                              )
                            ]),
                      )),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }

感谢您的帮助

【问题讨论】:

    标签: flutter syncfusion syncfusion-chart


    【解决方案1】:

    我们已经根据我们提供的信息分析了您的查询,我们发现在图表的数据源中,蜡烛数据点的开盘和收盘值相同,因此只有一条水平线为该数据点绘制以指示开盘值和收盘值相同。这是 CandleSeries 的默认行为。此外,还有一个名为 showIndicationForSameValues 的属性,当启用该属性为 true 时,会为高低值相同的数据点绘制一条细垂直线。有关数据点指示功能的进一步参考,请查看下面的用户指南。

    https://help.syncfusion.com/flutter/cartesian-charts/chart-types#indication-for-same-values-1

    此外,我们在下面分享了 Flutter 示例 GitHub 存储库链接,其中包含 Flutter 小部件的演示示例,这将有助于试验 Flutter 小部件中可用的功能。 Syncfusion Flutter 示例 GitHub 链接:https://github.com/syncfusion/flutter-examples

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多