codecov-io: ## [Current coverage](https://codecov.io/gh/napjon/krisk/pull/39?src=pr) is 91.69% (diff: 0.00%)
> Merging [#39](https://codecov.io/gh/napjon/krisk/pull/39?src=pr) into [0.2-develop](https://codecov.io/gh/napjon/krisk/branch/0.2-develop?src=pr) will decrease coverage by **1.95%**

```diff
@@           0.2-develop        #39   diff @@
=============================================
  Files               10         10          
  Lines              299        301     +2   
  Methods              0          0          
  Messages             0          0          
  Branches            39         40     +1   
=============================================
- Hits               280        276     -4   
- Misses               9         13     +4   
- Partials            10         12     +2   
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [b7489f4...71201fa](https://codecov.io/gh/napjon/krisk/compare/b7489f45df16b6805b2f576d696dabc1a3bc5235...71201faa3b06c668a6422c677f3fb64dad2253a7?src=pr)
diff --git a/krisk/plot/__init__.py b/krisk/plot/__init__.py
index 14e24b8..e702c4a 100644
--- a/krisk/plot/__init__.py
+++ b/krisk/plot/__init__.py
@@ -8,7 +8,8 @@ def bar(df,
         how='count',
         stacked=False,
         annotate=None,
-        full=False):
+        full=False,
+        trendline=False):
     """
     Parameters
     ----------
@@ -26,10 +27,13 @@ def bar(df,
     stacked: Boolean, default to False.
         Whether to stacked category on top of the other categories.
     annotate: string, {'all',True} default to None
-        if True, annotate value on top of the plot element. If stacked is also True, annotate the last
-        category. if 'all' and stacked, annotate all category
+        if True, annotate value on top of the plot element. If stacked is also True, annotate the 
+        last category. if 'all' and stacked, annotate all category
     full: boolean, default to False.
         If true, set to full area stacked chart. Only work if stacked is True.
+    trendline: boolean, default to False.
+        If true, add line that connected the bars. Only work if not category, category but stacked,
+        or not full.  
     
     Returns
     -------
@@ -39,6 +43,7 @@ def bar(df,
     # TODO: add optional argument trendline
 
     return make_chart(df,type='bar',x=x,y=y,c=c,how=how,stacked=stacked,full=full,
+                      trendline=trendline,
                       annotate='top' if annotate == True else annotate)
 
 
diff --git a/krisk/plot/bar_line.py b/krisk/plot/bar_line.py
index 057ed1d..1101415 100644
--- a/krisk/plot/bar_line.py
+++ b/krisk/plot/bar_line.py
@@ -51,6 +51,20 @@ def set_bar_line_chart(chart, df, x, c, **kwargs):
     if kwargs['annotate'] == 'top':
         series[-1]['label'] = d_annotate
 
+    if kwargs['type'] == 'bar' and kwargs['trendline']:
+        trendline = {'name':'trendline', 'type': 'line'}
+
+        if c and kwargs['stacked']:
+            trendline['data']  =  [0] * len(series[-1]['data'])
+            trendline['stack'] = c
+        elif c is None:
+            trendline['data'] = series[0]['data']
+        else:
+            raise AssertionError('Trendline must either stacked category, or not category')
+
+        series.append(trendline)
+
+
     
     # TODO: make annotate receive all kinds supported in echarts.
 

Add trendline parameters for bar chart
Add trendline that shows changes for bar chart
diff --git a/krisk/tests/data/bar_year_pop_mean_continent_trendline.json b/krisk/tests/data/bar_year_pop_mean_continent_trendline.json
new file mode 100644
index 0000000..89aa040
--- /dev/null
+++ b/krisk/tests/data/bar_year_pop_mean_continent_trendline.json
@@ -0,0 +1,152 @@
+{
+    "legend": {
+        "data": [
+            "Africa",
+            "Americas",
+            "Asia",
+            "Europe",
+            "Oceania"
+        ]
+    },
+    "title": {
+        "text": ""
+    },
+    "yAxis": {},
+    "series": [
+        {
+            "stack": "continent",
+            "type": "bar",
+            "data": [
+                9279525,
+                10270856,
+                11000948,
+                12760499,
+                14760787,
+                17152804,
+                20033753,
+                23254956,
+                26298373,
+                29072015,
+                31287142,
+                33333216
+            ],
+            "name": "Africa"
+        },
+        {
+            "stack": "continent",
+            "type": "bar",
+            "data": [
+                17876956,
+                19610538,
+                21283783,
+                22934225,
+                24779799,
+                26983828,
+                29341374,
+                31620918,
+                33958947,
+                36203463,
+                38331121,
+                40301927
+            ],
+            "name": "Americas"
+        },
+        {
+            "stack": "continent",
+            "type": "bar",
+            "data": [
+                8425333,
+                9240934,
+                10267083,
+                11537966,
+                13079460,
+                14880372,
+                12881816,
+                13867957,
+                16317921,
+                22227415,
+                25268405,
+                31889923
+            ],
+            "name": "Asia"
+        },
+        {
+            "stack": "continent",
+            "type": "bar",
+            "data": [
+                1282697,
+                1476505,
+                1728137,
+                1984060,
+                2263554,
+                2509048,
+                2780097,
+                3075321,
+                3326498,
+                3428038,
+                3508512,
+                3600523
+            ],
+            "name": "Europe"
+        },
+        {
+            "stack": "continent",
+            "type": "bar",
+            "data": [
+                8691212,
+                9712569,
+                10794968,
+                11872264,
+                13177000,
+                14074100,
+                15184200,
+                16257249,
+                17481977,
+                18565243,
+                19546792,
+                20434176
+            ],
+            "name": "Oceania"
+        },
+        {
+            "stack": "continent",
+            "data": [
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0,
+                0
+            ],
+            "type": "line",
+            "name": "trendline"
+        }
+    ],
+    "tooltip": {
+        "axisPointer": {
+            "type": ""
+        }
+    },
+    "xAxis": {
+        "data": [
+            1952,
+            1957,
+            1962,
+            1967,
+            1972,
+            1977,
+            1982,
+            1987,
+            1992,
+            1997,
+            2002,
+            2007
+        ]
+    }
+}
\ No newline at end of file
diff --git a/krisk/tests/data/bar_year_pop_mean_trendline.json b/krisk/tests/data/bar_year_pop_mean_trendline.json
new file mode 100644
index 0000000..15ef467
--- /dev/null
+++ b/krisk/tests/data/bar_year_pop_mean_trendline.json
@@ -0,0 +1,68 @@
+{
+    "legend": {
+        "data": []
+    },
+    "title": {
+        "text": ""
+    },
+    "yAxis": {},
+    "series": [
+        {
+            "type": "bar",
+            "data": [
+                9111144.6,
+                10062280.4,
+                11014983.8,
+                12217802.8,
+                13612120.0,
+                15120030.4,
+                16044248.0,
+                17615280.2,
+                19476743.2,
+                21899234.8,
+                23588394.4,
+                25911953.0
+            ],
+            "name": "year"
+        },
+        {
+            "data": [
+                9111144.6,
+                10062280.4,
+                11014983.8,
+                12217802.8,
+                13612120.0,
+                15120030.4,
+                16044248.0,
+                17615280.2,
+                19476743.2,
+                21899234.8,
+                23588394.4,
+                25911953.0
+            ],
+            "type": "line",
+            "name": "trendline"
+        }
+    ],
+    "tooltip": {
+        "axisPointer": {
+            "type": ""
+        }
+    },
+    "xAxis": {
+        "data": [
+            1952,
+            1957,
+            1962,
+            1967,
+            1972,
+            1977,
+            1982,
+            1987,
+            1992,
+            1997,
+            2002,
+            2007
+        ]
+    }
+}
\ No newline at end of file
diff --git a/krisk/tests/test_plot.py b/krisk/tests/test_plot.py
index 41aed67..bdce2e5 100644
--- a/krisk/tests/test_plot.py
+++ b/krisk/tests/test_plot.py
@@ -77,6 +77,20 @@ def test_full_bar_line(gapminder):
 
     assert bar.option == line.option == true_option
 
+
+def test_trendline(gapminder):
+
+    p = kk.bar(gapminder,'year',how='mean',y='pop',trendline=True)
+    assert p.get_option() == read_option_tests('bar_year_pop_mean_trendline.json')
+
+    p = kk.bar(gapminder,'year',how='mean',y='pop',trendline=True,c='continent',stacked=True)
+    assert p.get_option() == read_option_tests('bar_year_pop_mean_continent_trendline.json')
+
+    try:
+        kk.bar(gapminder,'year',how='mean',y='pop',trendline=True,c='continent')
+    except AssertionError:
+        pass
+
 def test_hist(gapminder):
 
     true_option  = read_option_tests('hist_x.json')

pip install -e .
parse_log_pytest
requirements.txt
pytest coverage
3.5
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
anyio==3.6.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
async-generator==1.10
attrs==22.2.0
Babel==2.11.0
backcall==0.2.0
bleach==4.1.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
comm==0.1.4
contextvars==2.4
coverage==6.2
dataclasses==0.8
decorator==5.1.1
defusedxml==0.7.1
entrypoints==0.4
idna==3.10
immutables==0.19
importlib-metadata==4.8.3
iniconfig==1.1.1
ipykernel==5.5.6
ipython==7.16.3
ipython-genutils==0.2.0
ipywidgets==7.8.5
jedi==0.17.2
Jinja2==3.0.3
json5==0.9.16
jsonschema==3.2.0
jupyter==1.1.1
jupyter-client==7.1.2
jupyter-console==6.4.3
jupyter-core==4.9.2
jupyter-server==1.13.1
jupyterlab==3.2.9
jupyterlab-pygments==0.1.2
jupyterlab-server==2.10.3
jupyterlab_widgets==1.1.11
-e git+https://github.com/napjon/krisk.git@b7489f45df16b6805b2f576d696dabc1a3bc5235#egg=krisk
MarkupSafe==2.0.1
mistune==0.8.4
nbclassic==0.3.5
nbclient==0.5.9
nbconvert==6.0.7
nbformat==5.1.3
nest-asyncio==1.6.0
notebook==6.4.10
numpy==1.19.5
packaging==21.3
pandas==1.1.5
pandocfilters==1.5.1
parso==0.7.1
pexpect==4.9.0
pickleshare==0.7.5
pluggy==1.0.0
prometheus-client==0.17.1
prompt-toolkit==3.0.36
ptyprocess==0.7.0
py==1.11.0
pycparser==2.21
Pygments==2.14.0
pyparsing==3.1.4
pyrsistent==0.18.0
pytest==7.0.1
python-dateutil==2.9.0.post0
pytz==2025.2
pyzmq==25.1.2
requests==2.27.1
Send2Trash==1.8.3
six==1.17.0
sniffio==1.2.0
terminado==0.12.1
testpath==0.6.0
tomli==1.2.3
tornado==6.1
traitlets==4.3.3
typing_extensions==4.1.1
urllib3==1.26.20
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.3.1
widgetsnbextension==3.6.10
zipp==3.6.0

name: krisk
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - anyio==3.6.2
      - argon2-cffi==21.3.0
      - argon2-cffi-bindings==21.2.0
      - async-generator==1.10
      - attrs==22.2.0
      - babel==2.11.0
      - backcall==0.2.0
      - bleach==4.1.0
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - comm==0.1.4
      - contextvars==2.4
      - coverage==6.2
      - dataclasses==0.8
      - decorator==5.1.1
      - defusedxml==0.7.1
      - entrypoints==0.4
      - idna==3.10
      - immutables==0.19
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - ipykernel==5.5.6
      - ipython==7.16.3
      - ipython-genutils==0.2.0
      - ipywidgets==7.8.5
      - jedi==0.17.2
      - jinja2==3.0.3
      - json5==0.9.16
      - jsonschema==3.2.0
      - jupyter==1.1.1
      - jupyter-client==7.1.2
      - jupyter-console==6.4.3
      - jupyter-core==4.9.2
      - jupyter-server==1.13.1
      - jupyterlab==3.2.9
      - jupyterlab-pygments==0.1.2
      - jupyterlab-server==2.10.3
      - jupyterlab-widgets==1.1.11
      - markupsafe==2.0.1
      - mistune==0.8.4
      - nbclassic==0.3.5
      - nbclient==0.5.9
      - nbconvert==6.0.7
      - nbformat==5.1.3
      - nest-asyncio==1.6.0
      - notebook==6.4.10
      - numpy==1.19.5
      - packaging==21.3
      - pandas==1.1.5
      - pandocfilters==1.5.1
      - parso==0.7.1
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pluggy==1.0.0
      - prometheus-client==0.17.1
      - prompt-toolkit==3.0.36
      - ptyprocess==0.7.0
      - py==1.11.0
      - pycparser==2.21
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pyrsistent==0.18.0
      - pytest==7.0.1
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyzmq==25.1.2
      - requests==2.27.1
      - send2trash==1.8.3
      - six==1.17.0
      - sniffio==1.2.0
      - terminado==0.12.1
      - testpath==0.6.0
      - tomli==1.2.3
      - tornado==6.1
      - traitlets==4.3.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - websocket-client==1.3.1
      - widgetsnbextension==3.6.10
      - zipp==3.6.0
prefix: /opt/conda/envs/krisk

krisk/tests/test_plot.py::test_trendline
krisk/tests/test_plot.py::test_bar krisk/tests/test_plot.py::test_line krisk/tests/test_plot.py::test_full_bar_line krisk/tests/test_plot.py::test_hist krisk/tests/test_plot.py::test_scatter
krisk/plot/bar_line.py krisk/plot/__init__.py
krisk/plot/bar_line.py krisk/plot/__init__.py