Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit ec80926

Browse files
Merge pull request #662 from deckgo/bar-chart-min
feat: bar chart y axis min
2 parents f82f1f0 + aff58c2 commit ec80926

File tree

8 files changed

+429
-324
lines changed

8 files changed

+429
-324
lines changed

docs/docs/components/app-components-charts/app-components-charts.md

Lines changed: 127 additions & 161 deletions
Large diffs are not rendered by default.

docs/src/app/pages/docs/components/app-components-charts/app-components-charts.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,6 +1559,18 @@ export class AppComponentsCharts {
15591559
<code>false</code>
15601560
</td>
15611561
</tr>
1562+
<tr>
1563+
<td>
1564+
<code>yAxisMin</code>
1565+
</td>
1566+
<td>
1567+
<code>y-axis-min</code>
1568+
</td>
1569+
<td></td>
1570+
<td>Set a minimal value for the y Axis. Useful in case the series of data could contains only zeros.</td>
1571+
<td></td>
1572+
<td></td>
1573+
</tr>
15621574
</tbody>
15631575
</table>
15641576
<p>

webcomponents/charts/CHANGELOG.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,119 @@
1+
<a name="1.0.0-rc.6-1"></a>
2+
3+
# 1.0.0-rc.6-1 (2020-01-16)
4+
5+
- add option `yAxisMin` to set a minimal value for the y Axis. useful in case the series of data could contains only zeros.
6+
17
<a name="1.0.0-rc.6"></a>
8+
29
# 1.0.0-rc.6 (2020-01-16)
310

4-
* add option to custom load (fetch) the data
11+
- add option to custom load (fetch) the data
512

613
<a name="1.0.0-rc.5"></a>
14+
715
# 1.0.0-rc.5 (2019-11-30)
816

9-
* update margin and positioning of the charts
17+
- update margin and positioning of the charts
1018

1119
<a name="1.0.0-rc.4"></a>
20+
1221
# 1.0.0-rc.4 (2019-11-30)
1322

1423
### Features
1524

16-
* add new property `data` and `yAxis` to the bar chart
17-
* add new method `updateCurrentBar()` to the bar chart
18-
* add new CSS variables for the fonts to the charts
25+
- add new property `data` and `yAxis` to the bar chart
26+
- add new method `updateCurrentBar()` to the bar chart
27+
- add new CSS variables for the fonts to the charts
1928

20-
Note: some **major** internal modifications where developed to the bar chart in order to integrate it to the new `poll` template
29+
Note: some **major** internal modifications where developed to the bar chart in order to integrate it to the new `poll` template
2130

2231
<a name="1.0.0-rc.3-1"></a>
32+
2333
# 1.0.0-rc.3-1 (2019-10-20)
2434

2535
### Fix
2636

27-
* custom labels for x-axis compatible with ES5
37+
- custom labels for x-axis compatible with ES5
2838

2939
<a name="1.0.0-rc.3"></a>
40+
3041
# 1.0.0-rc.3 (2019-10-19)
3142

3243
### Breaking changes
3344

34-
* indexing of the style of `line bar` chart has been moved from index `0` to begin with `1`
35-
* property `range` replaced by CSS4 variables generated dynamically
45+
- indexing of the style of `line bar` chart has been moved from index `0` to begin with `1`
46+
- property `range` replaced by CSS4 variables generated dynamically
3647

3748
### Features
3849

39-
* add a new CSS4 variable `--deckgo-chart-stroke` in case you would like to use a default styling color for all the graphs' lines
40-
* update most recent libs
50+
- add a new CSS4 variable `--deckgo-chart-stroke` in case you would like to use a default styling color for all the graphs' lines
51+
- update most recent libs
4152

4253
<a name="1.0.0-rc.2"></a>
54+
4355
# 1.0.0-rc.2 (2019-10-09)
4456

4557
### Features
4658

47-
* when using animation bar, allow custom labels for x-axis ([#340](https://github.com/deckgo/deckdeckgo/issues/340))
59+
- when using animation bar, allow custom labels for x-axis ([#340](https://github.com/deckgo/deckdeckgo/issues/340))
4860

4961
<a name="1.0.0-rc.1"></a>
62+
5063
# 1.0.0-rc.1 (2019-08-30)
5164

5265
### Libs
5366

54-
* update to most recent dependencies
67+
- update to most recent dependencies
5568

5669
### Note about v1.0.0-rc.1
5770

58-
The first users began to test, and to create content in, our web open source editor for presentations (`studio`)
71+
The first users began to test, and to create content in, our web open source editor for presentations (`studio`)
5972

6073
<a name="1.0.0-alpha.8"></a>
74+
6175
# 1.0.0-alpha.8 (2019-06-24)
6276

6377
### Features
6478

65-
* animated charts: it is now possible to display several data in the same graphs. these could be displayed one after the others with a nice transition between these
79+
- animated charts: it is now possible to display several data in the same graphs. these could be displayed one after the others with a nice transition between these
6680

6781
### Breaking
6882

69-
* the styling (fill color, etc.) of the `line` and `bar` chart has been modified
70-
* per default, the labels of the axis of the `line` and `bar` will be displayed
83+
- the styling (fill color, etc.) of the `line` and `bar` chart has been modified
84+
- per default, the labels of the axis of the `line` and `bar` will be displayed
7185

7286
Referer to the updated [documentation](https://docs.deckdeckgo.com) for more information.
7387

7488
<a name="1.0.0-alpha.7"></a>
89+
7590
# 1.0.0-alpha.7 (2019-06-04)
7691

7792
### Libs
7893

79-
* upgrade to Stencil One
94+
- upgrade to Stencil One
8095

8196
<a name="1.0.0-alpha.6"></a>
97+
8298
# 1.0.0-alpha.6 (2019-05-24)
8399

84100
### Breaking
85101

86-
* move to the org scoped package `@deckdeckgo/charts`
102+
- move to the org scoped package `@deckdeckgo/charts`
87103

88104
<a name="1.0.0-alpha.5"></a>
105+
89106
# [1.0.0-alpha.5](https://github.com/fluster/deckdeckgo-charts/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2019-02-07)
90107

91108
### Features
92109

93-
* feat: redraw chart if width, height or src change ([01aa026](https://github.com/deckgo/deckdeckgo-charts/commit/01aa026f0ab746684abf1e9e83b975ea15eaaef1))
94-
* feat: add text variable to bar and line charts ([54cbbb2](https://github.com/deckgo/deckdeckgo-charts/commit/54cbbb2a11a4873e9462b48dd41d0fb6985d5ef5))
110+
- feat: redraw chart if width, height or src change ([01aa026](https://github.com/deckgo/deckdeckgo-charts/commit/01aa026f0ab746684abf1e9e83b975ea15eaaef1))
111+
- feat: add text variable to bar and line charts ([54cbbb2](https://github.com/deckgo/deckdeckgo-charts/commit/54cbbb2a11a4873e9462b48dd41d0fb6985d5ef5))
95112

96113
<a name="1.0.0-alpha.4"></a>
114+
97115
# [1.0.0-alpha.4](https://github.com/fluster/deckdeckgo-charts/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2019-02-02)
98116

99117
### Lib
100118

101-
* update Stencil and d3js ([530c090](https://github.com/deckgo/deckdeckgo-charts/commit/530c090eb85862576758c31886c9d38d1c2c98df))
119+
- update Stencil and d3js ([530c090](https://github.com/deckgo/deckdeckgo-charts/commit/530c090eb85862576758c31886c9d38d1c2c98df))

webcomponents/charts/package-lock.json

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webcomponents/charts/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deckdeckgo/charts",
3-
"version": "1.0.0-rc.6",
3+
"version": "1.0.0-rc.6-1",
44
"description": "A collection of Web Components to easily draw charts",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",
@@ -29,24 +29,24 @@
2929
"d3-selection": "^1.4.1",
3030
"d3-shape": "^1.3.7",
3131
"d3-transition": "^1.3.2",
32-
"date-fns": "^2.9.0"
32+
"date-fns": "^2.10.0"
3333
},
3434
"devDependencies": {
3535
"@deckdeckgo/types": "^1.0.0-rc.4-1",
36-
"@stencil/core": "^1.8.5",
36+
"@stencil/core": "^1.8.11",
3737
"@stencil/postcss": "^1.0.1",
3838
"@stencil/sass": "^1.1.1",
3939
"@stencil/utils": "0.0.5",
4040
"@types/d3-array": "^2.0.0",
4141
"@types/d3-axis": "^1.0.12",
4242
"@types/d3-ease": "^1.0.9",
43-
"@types/d3-scale": "^2.1.1",
43+
"@types/d3-scale": "^2.2.0",
4444
"@types/d3-scale-chromatic": "^1.3.1",
4545
"@types/d3-selection": "^1.4.1",
4646
"@types/d3-shape": "^1.3.2",
47-
"@types/d3-transition": "^1.1.5",
47+
"@types/d3-transition": "^1.1.6",
4848
"autoprefixer": "^9.7.4",
49-
"husky": "^4.2.1",
49+
"husky": "^4.2.3",
5050
"prettier": "1.19.1",
5151
"pretty-quick": "^2.0.1"
5252
},

webcomponents/charts/src/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export namespace Components {
3434
'updateCurrentBar': (values: DeckdeckgoBarChartDataValue[]) => Promise<void>;
3535
'width': number;
3636
'yAxis': boolean;
37+
'yAxisMin': number;
3738
}
3839
interface DeckgoLineChart {
3940
'animation': boolean;
@@ -125,6 +126,7 @@ declare namespace LocalJSX {
125126
'src'?: string;
126127
'width'?: number;
127128
'yAxis'?: boolean;
129+
'yAxisMin'?: number;
128130
}
129131
interface DeckgoLineChart {
130132
'animation'?: boolean;

webcomponents/charts/src/components/charts/deckdeckgo-bar-chart/deckdeckgo-bar-chart.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export class DeckdeckgoBarChart implements DeckdeckgoChart {
4848

4949
@Prop() yAxis: boolean = true;
5050

51+
@Prop() yAxisMin: number = 0;
52+
5153
@Event()
5254
private chartCustomLoad: EventEmitter<string>;
5355

@@ -160,14 +162,13 @@ export class DeckdeckgoBarChart implements DeckdeckgoChart {
160162

161163
private initAxisYDomain(): Promise<void> {
162164
return new Promise<void>((resolve) => {
163-
this.y.domain([
164-
0,
165-
max(this.chartData, (category) => {
166-
return max(category.values, (d) => {
167-
return d.value;
168-
});
169-
})
170-
]);
165+
const maxValue: number = max(this.chartData, (category) => {
166+
return max(category.values, (d) => {
167+
return d.value;
168+
});
169+
});
170+
171+
this.y.domain([0, Math.max(this.yAxisMin, maxValue)]);
171172

172173
resolve();
173174
});

0 commit comments

Comments
 (0)