ui5-cc-chart 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@commitlint/config-conventional"]
3
+ }
package/.editorconfig ADDED
@@ -0,0 +1,22 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+ # We recommend you to keep these unchanged
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
13
+
14
+ # Change these settings to your own preference
15
+ indent_style = tab
16
+
17
+ [*.{yaml,yml,md,json,xml,properties}]
18
+ indent_size = 2
19
+ indent_style = space
20
+
21
+ [*.md]
22
+ trim_trailing_whitespace = false
@@ -0,0 +1,54 @@
1
+ name: Publish
2
+
3
+ # Trigger on tag push AND manual trigger
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*.*.*"
8
+ workflow_dispatch: # Manual trigger
9
+
10
+ permissions:
11
+ contents: read
12
+ id-token: write # REQUIRED for trusted publishing (OIDC)
13
+
14
+ jobs:
15
+ publish:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: 24
24
+ cache: "npm"
25
+ registry-url: "https://registry.npmjs.org/"
26
+
27
+ - name: Read package name
28
+ id: pkg
29
+ run: |
30
+ echo "NAME=$(jq -r '.name' package.json)" >> $GITHUB_ENV
31
+
32
+ - name: Decide publish method
33
+ run: |
34
+ if npm view "$NAME" > /dev/null 2>&1; then
35
+ echo "EXISTS=true" >> $GITHUB_ENV
36
+ echo "Package exists → using trusted publishing"
37
+ else
38
+ echo "EXISTS=false" >> $GITHUB_ENV
39
+ echo "Package does not exist → bootstrap publish"
40
+ fi
41
+
42
+ - name: Publish
43
+ env:
44
+ NPM_BOOTSTRAP_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }}
45
+ run: |
46
+ if [ "$EXISTS" = "false" ]; then
47
+ echo "//registry.npmjs.org/:_authToken=${NPM_BOOTSTRAP_TOKEN}" > ~/.npmrc
48
+ fi
49
+
50
+ npm publish --access public
51
+
52
+ if [ "$EXISTS" = "false" ]; then
53
+ rm ~/.npmrc
54
+ fi
@@ -0,0 +1 @@
1
+ npm run hooks:pre-commit
@@ -0,0 +1 @@
1
+ npm run hooks:pre-push
@@ -0,0 +1,3 @@
1
+ {
2
+ "**/*.js": "eslint"
3
+ }
@@ -0,0 +1,12 @@
1
+ # Ignore specific files
2
+ package-lock.json
3
+
4
+ # Ignore build output folders
5
+ /docs/**
6
+ /webapp/**
7
+
8
+ # Ignore files by extension
9
+ /**/*.svg
10
+ /**/*.png
11
+ /**/*.md
12
+
@@ -0,0 +1,18 @@
1
+ {
2
+ "singleQuote": false,
3
+ "printWidth": 200,
4
+ "endOfLine": "lf",
5
+ "tabWidth": 4,
6
+ "useTabs": true,
7
+ "overrides": [
8
+ {
9
+ "files": ["*.yaml", "*.yml", "*.md", "*.json", "*.xml", "*.properties"],
10
+ "options": {
11
+ "useTabs": false,
12
+ "tabWidth": 2,
13
+ "keySeparator": "=",
14
+ "xmlWhitespaceSensitivity": "ignore"
15
+ }
16
+ }
17
+ ]
18
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## 0.1.1 (2022-05-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * make line chart the default ([bd41b41](https://github.com/ui5-community/ui5-cc-chart/commit/bd41b4199c487a041d63b982bd87ed50c9077f3b))
7
+
8
+
9
+ ### Features
10
+
11
+ * finalize public project ([6291ba6](https://github.com/ui5-community/ui5-cc-chart/commit/6291ba6102e7d15c1c8a50ff73770e4f842a55cd))
12
+
13
+
14
+
package/Chart.css CHANGED
@@ -1,3 +1,3 @@
1
1
  .chart {
2
- padding: 4rem;
2
+ padding: 4rem;
3
3
  }
package/Chart.js CHANGED
@@ -1,71 +1,71 @@
1
- sap.ui.define(["sap/ui/core/Control", "chart.js/auto", "sap/ui/dom/includeStylesheet"], function(Control, Chart, includeStylesheet) {
1
+ sap.ui.define(["sap/ui/core/Control", "chart.js/auto", "sap/ui/dom/includeStylesheet"], function (Control, Chart, includeStylesheet) {
2
+ return Control.extend("ui5-cc-chart.Chart", {
3
+ metadata: {
4
+ properties: {
5
+ type: {
6
+ type: "string",
7
+ defaultValue: "line",
8
+ },
9
+ title: "string",
10
+ color: "sap.ui.core.CSSColor",
11
+ },
12
+ aggregations: {
13
+ records: {
14
+ type: "ui5-cc-chart.ChartRecord",
15
+ },
16
+ },
17
+ defaultAggregation: "records",
18
+ },
19
+ renderer: {
20
+ apiVersion: 2,
21
+ render: function (rm, chart) {
22
+ rm.openStart("div", chart);
23
+ rm.style("color", chart.getColor());
24
+ rm.class("chart");
25
+ rm.openEnd();
2
26
 
3
- return Control.extend("ui5-cc-chart.Chart", {
4
- metadata: {
5
- properties: {
6
- "type": {
7
- type: "string",
8
- defaultValue: "line"
9
- },
10
- "title": "string",
11
- "color": "sap.ui.core.CSSColor"
12
- },
13
- aggregations: {
14
- "records": {
15
- type: "ui5-cc-chart.ChartRecord"
16
- }
17
- },
18
- defaultAggregation: "records"
19
- },
20
- renderer: {
21
- apiVersion: 2,
22
- render: function(rm, chart) {
23
- rm.openStart("div", chart);
24
- rm.style("color", chart.getColor());
25
- rm.class("chart");
26
- rm.openEnd();
27
-
28
- rm.openStart("canvas", chart.getId() + "-canvas");
29
- rm.openEnd();
30
- rm.close("canvas");
31
-
32
- rm.close("div");
33
- }
34
- },
35
- _getChartData: function() {
36
- const aRecords = this.getRecords();
37
- return {
38
- labels: aRecords.map(record => {
39
- return record.getLabel();
40
- }),
41
- datasets: [{
42
- label: this.getTitle(),
43
- backgroundColor: this.getColor(),
44
- borderColor: this.getColor(),
45
- data: aRecords.map(record => {
46
- return record.getValue();
47
- })
48
- }]
49
- };
50
- },
51
- init: function() {
52
- includeStylesheet(sap.ui.require.toUrl("ui5-cc-chart/Chart.css"));
53
- },
54
- onAfterRendering: function() {
55
- if (!this._chart) {
56
- this._chart = new Chart(this.getDomRef("canvas"), {
57
- type: this.getType(),
58
- data: this._getChartData(),
59
- options: {
60
- responsive: true,
61
- animation: false
62
- }
63
- });
64
- } else {
65
- this._chart.data = this._getChartData();
66
- this._chart.update();
67
- }
68
- }
69
- });
27
+ rm.openStart("canvas", chart.getId() + "-canvas");
28
+ rm.openEnd();
29
+ rm.close("canvas");
70
30
 
31
+ rm.close("div");
32
+ },
33
+ },
34
+ _getChartData: function () {
35
+ const aRecords = this.getRecords();
36
+ return {
37
+ labels: aRecords.map((record) => {
38
+ return record.getLabel();
39
+ }),
40
+ datasets: [
41
+ {
42
+ label: this.getTitle(),
43
+ backgroundColor: this.getColor(),
44
+ borderColor: this.getColor(),
45
+ data: aRecords.map((record) => {
46
+ return record.getValue();
47
+ }),
48
+ },
49
+ ],
50
+ };
51
+ },
52
+ init: function () {
53
+ includeStylesheet(sap.ui.require.toUrl("ui5-cc-chart/Chart.css"));
54
+ },
55
+ onAfterRendering: function () {
56
+ if (!this._chart) {
57
+ this._chart = new Chart(this.getDomRef("canvas"), {
58
+ type: this.getType(),
59
+ data: this._getChartData(),
60
+ options: {
61
+ responsive: true,
62
+ animation: false,
63
+ },
64
+ });
65
+ } else {
66
+ this._chart.data = this._getChartData();
67
+ this._chart.update();
68
+ }
69
+ },
70
+ });
71
71
  });
package/ChartRecord.js CHANGED
@@ -1,12 +1,10 @@
1
- sap.ui.define(["sap/ui/core/Element"], function(Element) {
2
-
3
- return Element.extend("ui5-cc-chart.ChartRecord", {
4
- metadata: {
5
- properties: {
6
- label: "string",
7
- value: "float"
8
- }
9
- }
10
- });
11
-
1
+ sap.ui.define(["sap/ui/core/Element"], function (Element) {
2
+ return Element.extend("ui5-cc-chart.ChartRecord", {
3
+ metadata: {
4
+ properties: {
5
+ label: "string",
6
+ value: "float",
7
+ },
8
+ },
9
+ });
12
10
  });
package/README.md CHANGED
@@ -78,6 +78,18 @@ Please use the GitHub bug tracking system to post questions, bug reports or to c
78
78
 
79
79
  Any type of contribution (code contributions, pull requests, issues) to this showcase will be equally appreciated.
80
80
 
81
+ ## Releasing
82
+
83
+ To release a new version of the package, you just need to run the following command:
84
+
85
+ ```sh
86
+ # Release a new version of the package
87
+ npm version [major|minor|patch]
88
+
89
+ # Publish the package (push the change and the tag)
90
+ npm run version:publish
91
+ ```
92
+
81
93
  ## License
82
94
 
83
95
  This work is [dual-licensed](../../LICENSE) under Apache 2.0 and the Derived Beer-ware License. The official license will be Apache 2.0 but finally you can choose between one of them if you use this work.
@@ -0,0 +1,22 @@
1
+ const globals = require("globals");
2
+ const js = require("@eslint/js");
3
+
4
+ module.exports = [
5
+ js.configs.recommended,
6
+ {
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.browser,
10
+ sap: "readonly",
11
+ },
12
+ ecmaVersion: 2023,
13
+ sourceType: "script",
14
+ },
15
+ rules: {
16
+ "prefer-const": "warn",
17
+ },
18
+ },
19
+ {
20
+ ignores: ["eslint.config.js"],
21
+ },
22
+ ];
package/package.json CHANGED
@@ -1,10 +1,39 @@
1
1
  {
2
2
  "name": "ui5-cc-chart",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "UI5 Custom Control: Chart.js",
5
5
  "author": "UI5 Community",
6
6
  "license": "Apache-2.0",
7
+ "repository": {
8
+ "url": "https://github.com/ui5-community/ui5-cc-chart"
9
+ },
10
+ "scripts": {
11
+ "lint": "eslint .",
12
+ "lint:staged": "lint-staged",
13
+ "lint:commit": "commitlint -e",
14
+ "prettier": "prettier --write .",
15
+ "prettier:staged": "pretty-quick --staged --verbose",
16
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
17
+ "hooks:pre-commit": "npm-run-all --sequential prettier:staged lint:staged",
18
+ "hooks:pre-push": "npm-run-all --sequential lint:commit",
19
+ "version": "npm run changelog && git add --all",
20
+ "version:publish": "git push && git push --tags"
21
+ },
7
22
  "dependencies": {
8
- "chart.js": "^3.7.1"
23
+ "chart.js": "^4.5.1"
24
+ },
25
+ "devDependencies": {
26
+ "@commitlint/cli": "^20.2.0",
27
+ "@commitlint/config-conventional": "^20.2.0",
28
+ "@prettier/plugin-xml": "^3.4.2",
29
+ "conventional-changelog-cli": "^5.0.0",
30
+ "eslint": "^9.39.2",
31
+ "globals": "^16.5.0",
32
+ "husky": "^9.1.7",
33
+ "lint-staged": "^16.2.7",
34
+ "npm-run-all": "^4.1.5",
35
+ "prettier": "^3.7.4",
36
+ "prettier-plugin-properties": "^0.3.1",
37
+ "pretty-quick": "^4.2.2"
9
38
  }
10
39
  }