我正在试验syncfusion
并试图获得如文档中所示的烛台图。不幸的是,当我尝试我的代码而不是看到蜡烛时,看到一条水平绿线,我不明白为什么。我使用了以下代码:
图表数据
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,
)
]),
)),
],
),
)
],
),
),
);
}
谢谢您的帮助