Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For stacked series, adds support for last value in series to be considered as total #711

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5e1f377
Update hacs.json
georgepauna May 14, 2024
8b0a00e
Create validate.yaml
georgepauna May 14, 2024
cba4181
Update validate.yaml
georgepauna May 14, 2024
d71f178
Update hacs.json
georgepauna May 14, 2024
c64db3e
Update release.yml
georgepauna May 14, 2024
9b8f1d5
Update package.json
georgepauna May 14, 2024
2a8f161
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 14, 2024
31e8fcb
Added option for last series to be total
georgepauna May 14, 2024
99befda
Update package.json
georgepauna May 14, 2024
e30fe05
Update package-lock.json
georgepauna May 14, 2024
2d26a05
Update package-lock.json
georgepauna May 14, 2024
49dbee6
Update apexcharts-card.ts
georgepauna May 14, 2024
9587950
Update package-lock.json
georgepauna May 14, 2024
2c3f86d
Update package.json
georgepauna May 14, 2024
05c4009
Update package-lock.json
georgepauna May 14, 2024
2cf71f8
Update package.json
georgepauna May 14, 2024
0a4f427
Update package-lock.json
georgepauna May 14, 2024
1351d2f
Update package.json
georgepauna May 14, 2024
6e99080
Update package.json
georgepauna May 14, 2024
5647717
Update package.json feat(total_stacked)
georgepauna May 14, 2024
0bdf2f5
Update package-lock.json fix(build)
georgepauna May 14, 2024
cefab5d
force fix(build)
georgepauna May 14, 2024
c2f9047
Update package-lock.json chore(build)
georgepauna May 14, 2024
72fefd2
Update package.json chore(build)
georgepauna May 14, 2024
4785d72
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 14, 2024
4e162e7
Fix total stack
georgepauna May 14, 2024
a10086a
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 14, 2024
0ccaba9
Merge branch 'master' of https://github.com/georgepauna/apexcharts-card
georgepauna May 14, 2024
fb055be
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 14, 2024
c092907
Fixes timestamps not matching in stacked graphs
georgepauna May 15, 2024
396745e
Merge branch 'master' of https://github.com/georgepauna/apexcharts-card
georgepauna May 15, 2024
d1933e3
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 15, 2024
ebf4729
Update apexcharts-card.ts
georgepauna Jun 17, 2024
99391f4
chore(release): 1.0.0 [skip ci]
semantic-release-bot Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Release

on: workflow_dispatch
on:
workflow_dispatch:

jobs:
release-bundle:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Validate

on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
validate-hacs:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: HACS validation
uses: "hacs/action@main"
with:
category: "plugin"
1,176 changes: 1,176 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ This card is available in [HACS](https://hacs.xyz/) (Home Assistant Community St
2. Grab `apexcharts-card.js`:

```
$ wget https://github.com/RomRider/apexcharts-card/releases/download/v2.0.4/apexcharts-card.js
$ wget https://github.com/RomRider/apexcharts-card/releases/download/v1.0.0/apexcharts-card.js
```

3. Add the resource reference as decribed below.
Expand All @@ -99,7 +99,7 @@ If you configure Lovelace via YAML, add a reference to `apexcharts-card.js` insi

```yaml
resources:
- url: /local/apexcharts-card.js?v=2.0.4
- url: /local/apexcharts-card.js?v=1.0.0
type: module
```

Expand Down Expand Up @@ -143,6 +143,7 @@ The card stricly validates all the options available (but not for the `apex_conf
| `hours_12` | boolean | | v1.8.0 | If undefined, it will follow Home-Assistant's user time format. If `true`, it will force time to be displayed in 12h format. If `false` it will force the time to be displayed in 24h format. |
| `cache` | boolean | `true` | v1.0.0 | Use in-browser data caching to reduce the load on Home Assistant's server |
| `stacked` | boolean | `false` | v1.0.0 | Enable if you want the data to be stacked on the graph |
| `stacked_last_is_total` | boolean | `false` | v1.0.0 | Enable if you want the last series data to be considered as total |
| `layout` | string | | v1.0.0 | See [layouts](#layouts) |
| `header` | object | | v1.0.0 | See [header](#header-options) |
| `now` | object | | v1.5.0 | See [now](#now-options) |
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apexcharts-card",
"version": "2.0.4",
"version": "1.0.0",
"description": "A Home Assistant Lovelace card using ApexCharts to render graphs",
"main": "src/apexcharts-card.ts",
"scripts": {
Expand All @@ -13,7 +13,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/RomRider/apexcharts-card.git"
"url": "git+https://github.com/georgepauna/apexcharts-card.git"
},
"keywords": [
"lovelace",
Expand All @@ -25,9 +25,9 @@
"author": "Jérôme Wiedemann",
"license": "MIT",
"bugs": {
"url": "https://github.com/RomRider/apexcharts-card/issues"
"url": "https://github.com/georgepauna/apexcharts-card/issues"
},
"homepage": "https://github.com/RomRider/apexcharts-card#readme",
"homepage": "https://github.com/georgepauna/apexcharts-card#readme",
"dependencies": {
"@ctrl/tinycolor": "^3.4.0",
"@material/mwc-ripple": "^0.25.3",
Expand Down
6 changes: 6 additions & 0 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,12 @@ class ChartsCard extends LitElement {
if (this._config?.series[index].show.in_brush) brushData.series.push(result);
return;
});

if (this._config.stacked_last_is_total)
for (let i = 0; i < graphData.series.length-1; i++)
for (let j = 0; j < graphData.series[i].data.length; j++)
graphData.series[graphData.series.length-1].data[j][1] -= graphData.series[i].data[j][1] || 0;

graphData.annotations = this._computeAnnotations(start, end, now);
if (this._yAxisConfig) {
graphData.yaxis = this._computeYAxisAutoMinMax(start, end);
Expand Down
1 change: 1 addition & 0 deletions src/types-config-ti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const ChartCardExternalConfig = t.iface([], {
})),
"cache": t.opt("boolean"),
"stacked": t.opt("boolean"),
"stacked_last_is_total": t.opt("boolean"),
"layout": t.opt("string"),
"apex_config": t.opt("any"),
"header": t.opt("ChartCardHeaderExternalConfig"),
Expand Down
1 change: 1 addition & 0 deletions src/types-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface ChartCardExternalConfig {
};
cache?: boolean;
stacked?: boolean;
stacked_last_is_total?: boolean;
layout?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
apex_config?: any;
Expand Down