adaptive-linechart 1.2.2 → 1.4.0

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.
package/tools/updoc.js ADDED
@@ -0,0 +1,35 @@
1
+ // Generates the API documentation from the JSDoc comments in the code
2
+ // and inserts it into README.md between the markers <!-- @API --> and
3
+ // <!-- /@API -->. If the markers don't exist yet, the section is inserted
4
+ // before the "# Public methods" chapter (or appended at the end).
5
+ //
6
+ // Usage: npm run updoc
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const jsdoc2md = require('jsdoc-to-markdown');
10
+
11
+ (async function () {
12
+ const readmePath = path.join(__dirname, '..', 'README.md');
13
+ let readme = fs.readFileSync(readmePath, 'utf8');
14
+
15
+ const api = await jsdoc2md.render({ files: path.join(__dirname, '..', 'src', 'linechart.js') });
16
+
17
+ const start = '<!-- @API -->';
18
+ const end = '<!-- /@API -->';
19
+ const section = start + '\n\n' + api.trim() + '\n\n' + end;
20
+
21
+ const markerRe = /<!-- @API -->[\s\S]*?<!-- \/@API -->/;
22
+ if (markerRe.test(readme)) {
23
+ readme = readme.replace(markerRe, section);
24
+ } else {
25
+ const anchor = '# Public methods';
26
+ if (readme.includes(anchor)) {
27
+ readme = readme.replace(anchor, section + '\n\n' + anchor);
28
+ } else {
29
+ readme += '\n\n' + section;
30
+ }
31
+ }
32
+
33
+ fs.writeFileSync(readmePath, readme);
34
+ console.log('README.md: API-Sektion aktualisiert');
35
+ })();
@@ -1,84 +0,0 @@
1
- document.addEventListener('DOMContentLoaded', function () {
2
- createCharts();
3
- });
4
-
5
- var isMobil = false;
6
- var request;
7
- var charts = [];
8
-
9
- // Example time-series. Semicolon separated pairs "Unix-Timestamp/Value;Unix-Timestamp/Value;.."
10
- // The values may be empty. The last element may be withoud value. It Indicate end of timespane
11
- // of this line.
12
- var arTimeSeries = [
13
- {
14
- name: 'Example one',
15
- data: '1565301600/-11.2;1565560800/-9;1565647200/-7.2;1565733600/-5.89;1565820000/-5.2;1565906400/-2.50;1566165600/-1.21;1566252000/0.20;1566338400/-2;1566424800/-4.5;1566511200/-6.2;1566770400/-8.3;1566856800/-10.0;1566943200/-11;1567029600/-13.8;1567116000/-15.8;1567461600/-12.9;1567548000/-8.9;1567634400/-8.94;1567720800/-10.96'
16
- },
17
- {
18
- name: 'Example Two',
19
- data: '1565301600/11.2;1565560800/6;1565647200/4;1565733600/2;1565820000/-2;1565906400/-3;1566165600/-4;1566252000/-6;1566338400/-7;1566424800/-8;1566511200/-8;1566770400/-5.5;1566856800/-3.6;1566943200/-0.6;1567029600/1.8;1567116000/3.8;1567461600/4.2;1567548000/5.4;1567634400/6.94;1567720800/7.96'
20
- },
21
- {
22
- name: 'Example Two',
23
- data: '1565301000/0;1565560200/-0.4;1565646600/-1.1;1565733000/-2;1565819400/-0.5;1565905800/-0.01;1566165000/0.2;1566252000/0.3;1566337800/2.2;1566424200/4.2;1566510600/5.2;1566779800/6.1;1566856200/7.4;1566942600/8;1567029000/8.2;1567115400/8.8;1567461000/9.2;1567547400/11.4;1567633800/12.94;1567720200/11.96'
24
- }
25
- ];
26
-
27
- function createCharts () {
28
-
29
- // Create first chart in div id "charts"
30
- let lchart;
31
-
32
- lchart = new LineChart(document.getElementById('charts'),null, null, 'Example Chart-Line', null);
33
-
34
- for(let i=0; i < arTimeSeries.length; i++) {
35
- let line = {
36
- obj_name: 'Chart',
37
- par_name: arTimeSeries[i].name,
38
- values: arTimeSeries[i].data
39
- };
40
- lchart.addLine(line);
41
- }
42
-
43
- lchart.draw();
44
-
45
- charts.push(lchart);
46
-
47
- // Example convert CSV to time-series
48
- request = new XMLHttpRequest();
49
- request.open("GET","example.csv");
50
- request.addEventListener('load', function(event) {
51
- if (request.status == 200) {
52
-
53
- // Convert SCV to format suitable for chart.
54
- let arTimeSeries = scvToTimeSeries(request.responseText);
55
-
56
- // Create next chart in div id "charts"
57
- lchart = new LineChart(document.getElementById('charts'),null, null, 'Example Chart-Line with data from CSV', null);
58
-
59
- for(let i=0; i < arTimeSeries.length - 1; i++) {
60
- let line = {
61
- obj_name: 'Stock preis',
62
- par_name: arTimeSeries[i].name,
63
- values: arTimeSeries[i].data
64
- };
65
- lchart.addLine(line);
66
- }
67
-
68
- lchart.draw();
69
-
70
- charts.push(lchart);
71
- } else {
72
-
73
- console.warn("Request CSV failed status "+ request.statusText+ " Responce "+ request.responseText);
74
- }
75
- });
76
-
77
- request.send();
78
- }
79
-
80
-
81
-
82
-
83
-
84
-
File without changes