Apex chart cart cumulative sum issue

I’m trying to do cumulative sum using Apexchart like history chart but there seems to be an issue when using apex chart card. Here is the history chart

chart_type: line
period: hour
type: statistics-graph
entities:
  - sensor.total_battery_in
  - entity: sensor.total_battery_out
    name: Out
stat_types:
  - sum
days_to_show: 1
title: Battery IN/OUT


However, the apex chart output is

type: custom:apexcharts-card
graph_span: 24h
span:
  start: day
  offset: +1h
header:
  show: true
series:
  - entity: sensor.total_battery_in
    type: line
    name: IN
    group_by:
      func: last
      duration: 1h

It seems to show the trend but the sum value is not correct.
Any suggestion?