fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

Will Candlestick Chart be Supported?

Open satrio1256 opened this issue 3 years ago • 17 comments

Candlestick chart usually used in finance application. Is it will be supported in the future?

ad7f5cb5151810c4438586bb45d49b078330e25a

download

satrio1256 avatar Sep 03 '20 06:09 satrio1256

Yes it will

imaNNeo avatar Sep 05 '20 17:09 imaNNeo

Maybe we could adapt this implementation (MIT licensed) : candlesticks

sachaarbonel avatar Dec 28 '20 12:12 sachaarbonel

Is there any plan for this new chart feature? this addition will be an amazing feature upgrade for the library.

khanhnguyen-96 avatar Apr 02 '21 04:04 khanhnguyen-96

this is an amazing package but I can not implement in my project without candlestick chart :(

cuongloveit avatar Apr 02 '21 04:04 cuongloveit

hope this Candlestick chart will be implemented soon! I really need it for my fintech project :(

manle93 avatar Apr 02 '21 04:04 manle93

please consider integrating candlestick charts like mp charts into this package. It will help almost all people

namtranx07 avatar Apr 02 '21 06:04 namtranx07

Still in waiting...

yingshaoxo avatar Aug 07 '21 23:08 yingshaoxo

image

cuong0993 avatar May 20 '22 17:05 cuong0993

Is candlestick like this ? (created by fl_chart) edit

sonjinho avatar Jun 15 '22 01:06 sonjinho

Is candlestick like this ? (created by fl_chart) edit

Yes. Can you share you code?

cuong0993 avatar Jun 24 '22 06:06 cuong0993

I use Barchart Group Data simple, @cuong0993

BarChartGroupData(x: 1, groupVertically: true, barRods: [ BarChartRodData( fromY: 2, toY: 10, width: 15, color: Colors.green, borderRadius: BorderRadius.zero), BarChartRodData(fromY: 0, toY: 15, width: 1, color: Colors.green) ])

sonjinho avatar Jun 28 '22 01:06 sonjinho

full code view Screenshot from 2022-06-30 14-50-21

data Screenshot from 2022-06-30 15-04-37

BarChart has issue for bottom AxisTitles So I use BarTouchData to show data #964

class CandleChart extends StatelessWidget {
  const CandleChart({Key? key, required this.stockChartDataList})
      : super(key: key);

  final List<StockChartDataDTO> stockChartDataList;
  @override
  Widget build(BuildContext context) {
    int i = 0;
    // format for korean
    const Color plusColor = Colors.red;
    const Color minusColor = Colors.blue;

    List<StockChartDataDTO> chartDataList = stockChartDataList;
    var barChartGroups = List<BarChartGroupData>.empty(growable: true);
    int minY = chartDataList[0].low;
    int maxY = chartDataList[0].high;
    for (var stockChartData in chartDataList) {
      barChartGroups.add(
        BarChartGroupData(
          x: i,
          groupVertically: true,
          barRods: [
            BarChartRodData(
                fromY: stockChartData.open.toDouble(),
                toY: stockChartData.close.toDouble(),
                width: 3,
                color: stockChartData.open < stockChartData.close
                    ? plusColor
                    : minusColor,
                borderRadius: BorderRadius.zero),
            BarChartRodData(
              fromY: stockChartData.low.toDouble(),
              toY: stockChartData.high.toDouble(),
              width: 1,
              color: stockChartData.open < stockChartData.close
                  ? plusColor
                  : minusColor,
            )
          ],
        ),
      );
      i++;
      minY = min(minY, stockChartData.low);
      maxY = max(maxY, stockChartData.high);
    }
    debugPrint('${chartDataList.length}');
    return BarChart(
      BarChartData(
          borderData: FlBorderData(
            border: Border.all(style: BorderStyle.solid),
          ),
          groupsSpace: 10,
          barTouchData: BarTouchData(
              touchTooltipData: BarTouchTooltipData(
            tooltipBgColor: Colors.white,
            getTooltipItem: (group, groupIndex, rod, rodIndex) {
              var stockChartData = chartDataList[groupIndex];
              int day = stockChartData.day;
              var date = DateTime.parse(day.toString());
              String touchData =
                  'open: ${stockChartData.open}\n close: ${stockChartData.close}\n high: ${stockChartData.high}\n low: ${stockChartData.low}\n day:${date.year % 100} . ${date.month} . ${date.day}';
              return BarTooltipItem(
                  touchData,
                  TextStyle(
                    color: stockChartData.open < stockChartData.close
                        ? plusColor
                        : minusColor,
                    fontWeight: FontWeight.bold,
                    fontSize: 10,
                  ));
            },
          )),
          barGroups: barChartGroups,
          minY: minY.toDouble(),
          maxY: maxY.toDouble(),
          titlesData: FlTitlesData(
            show: true,
            leftTitles: AxisTitles(
              sideTitles: SideTitles(showTitles: false),
            ),
            topTitles: AxisTitles(
              sideTitles: SideTitles(showTitles: false),
            ),
            bottomTitles: AxisTitles(
              sideTitles: SideTitles(
                showTitles: false,
              ),
            ),
            rightTitles: AxisTitles(
              sideTitles: SideTitles(
                showTitles: true,
                reservedSize: 30,
                interval: 2500,
                getTitlesWidget: (value, meta) {
                  int index = value.toInt();
                  if (value == meta.min || value == meta.max) {
                    return const SizedBox.shrink();
                  } else {
                    return Text(
                      meta.formattedValue,
                      style: const TextStyle(fontSize: 10),
                    );
                  }
                },
              ),
            ),
          )),
    );
  }
}


sonjinho avatar Jun 30 '22 05:06 sonjinho

Thank you. It looks great

cuong0993 avatar Jul 01 '22 04:07 cuong0993

Hello @imaNNeo, is this still in-progress? Are there plans to add support for this soon?

dawoodt avatar Jan 31 '23 07:01 dawoodt

Hello @imaNNeo, is this still in-progress? Are there plans to add support for this soon?

This is going to the first new chart type that we add. But I cannot guarantee any time-line to implement it.

imaNNeo avatar Jan 31 '23 08:01 imaNNeo

Any update on this @imaNNeo ?

JaredEzz avatar Dec 14 '23 19:12 JaredEzz

Any update on this @imaNNeo ?

Unfortunately nothing

imaNNeo avatar Dec 15 '23 21:12 imaNNeo