Skip to content

Commit ad34557

Browse files
v1.0.0
1 parent 02c4f98 commit ad34557

File tree

10 files changed

+691
-101
lines changed

10 files changed

+691
-101
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
node_modules
21
.DS_Store
2+
node_modules
3+
dist
34
npm-debug.log*
4-
.vscode
5+
.vscode

index.html

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script type="module" src="index.js" defer></script>
4+
<script type="module" src="dist/ternary-plot.umd.js" defer></script>
55
</head>
6+
<style>
7+
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,700&display=swap');
8+
/*
9+
CSS custom properties penetrate the Shadow DOM.
10+
They are useful to provide custom styling.
11+
*/
12+
ternary-plot {
13+
--font-size: 13px;
14+
--font-family: 'Roboto Mono', monospace;
15+
}
16+
</style>
617
<body>
7-
<h1>Test</h1>
818
<ternary-plot side="400"></ternary-plot>
919
</body>
20+
<script>
21+
const element = document.querySelector('ternary-plot');
22+
// Set data as a dynamic property.
23+
element.data = getRandomData(20);
24+
25+
function getRandomData (length) {
26+
return {
27+
titles: {
28+
bottom: "Variable A",
29+
right: "Variable B",
30+
left: "Variable C",
31+
},
32+
data: Array.from({length}, getRandomDatum),
33+
};
34+
}
35+
36+
function getRandomDatum () {
37+
const a = Math.random();
38+
const b = Math.random();
39+
const c = Math.random();
40+
const sum = a + b + c;
41+
return {
42+
bottom: a / sum,
43+
right: b / sum,
44+
left: c / sum
45+
};
46+
}
47+
</script>
1048
</html>

index.js

Lines changed: 0 additions & 87 deletions
This file was deleted.

license

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2019 Riccardo Scalco
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package-lock.json

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

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
"name": "ternary-plot",
33
"version": "1.0.0",
44
"description": "web component of a ternary plot.",
5-
"main": "index.js",
5+
"main": "dist/ternary-plot.cjs.js",
6+
"module": "dist/ternary-plot.esm.js",
7+
"browser": "dist/ternary-plot.umd.js",
68
"scripts": {
9+
"build": "rollup -c",
10+
"dev": "rollup -c -w",
11+
"pretest": "npm run build",
712
"test": "echo \"Error: no test specified\" && exit 1"
813
},
914
"keywords": [
@@ -13,8 +18,14 @@
1318
"component"
1419
],
1520
"author": "",
16-
"license": "ISC",
21+
"license": "MIT",
1722
"devDependencies": {
18-
"hybrids": "^4.0.2"
19-
}
23+
"hybrids": "^4.0.2",
24+
"rollup": "^1.14.3",
25+
"rollup-plugin-commonjs": "^10.0.0",
26+
"rollup-plugin-node-resolve": "^5.0.1"
27+
},
28+
"files": [
29+
"dist"
30+
]
2031
}

readme.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ternary-plot
2+
3+
Web component to implement a ternary plot.
4+
5+
## Usage
6+
7+
In an html file
8+
9+
```
10+
<html>
11+
<head>
12+
<script type="module">
13+
import 'ternary-plot/ternary-plot.umd.js';
14+
</script>
15+
</head>
16+
<body>
17+
<ternary-plot side="400"></ternary-plot>
18+
</body>
19+
<script>
20+
const element = document.querySelector('ternary-plot');
21+
// Set data as a dynamic property.
22+
element.data = {
23+
titles: {
24+
bottom: "Variable A",
25+
right: "Variable B",
26+
left: "Variable C",
27+
},
28+
data: [
29+
{
30+
bottom: 0.3,
31+
right: 0.4,
32+
left: 0.3
33+
},
34+
{
35+
bottom: 0.1,
36+
right: 0.5,
37+
left: 0.4
38+
},
39+
]
40+
};
41+
</script>
42+
</html>
43+
```
44+
45+
## License
46+
47+
MIT

0 commit comments

Comments
 (0)