hayun-vite 0.10.1 → 0.11.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/assets/data/sampleData.js +10 -2
- package/assets/templates/mainTemplate.js +128 -0
- package/assets/templates/template_combo.js +49 -44
- package/package.json +1 -1
- package/src/Audiogram/Audiogram.js +43 -21
- package/src/Audiogram/Audiogram_100.js +499 -0
- package/src/Audiogram/Audiogram_box.js +483 -0
- package/src/Audiogram/dims.js +4 -80
- package/src/Audiogram/dims_100.js +51 -0
- package/src/Audiogram/dims_box.js +125 -0
- package/src/{Form → Box}/Box.js +26 -3
- package/src/Form/Form.js +8 -8
- package/src/Form/Form_N.js +194 -0
- package/src/Form/Forms.js +0 -2
- package/src/Form/Sections.js +0 -6
- package/src/Form/Sections_N.js +66 -0
- package/src/{Form → Header}/Header.js +1 -4
- package/src/Header/Header_N.js +72 -0
- package/src/MultiText/MultiText.js +37 -0
- package/src/{Form/Reflex_N.js → Reflex/Reflex.js} +15 -3
- package/src/Reflex/units.js +65 -0
- package/src/{Form/Speech_N.js → Speech/Speech.js} +45 -28
- package/src/Speech/Speech_N.js +125 -0
- package/src/Speech/units.js +31 -0
- package/src/{Form → Tympanogram}/Tympanogram.js +37 -68
- package/src/Tympanogram/units.js +76 -0
- package/src/common/{putTextBox.js → putCell.js} +6 -6
- package/src/common/putG.js +10 -0
- package/src/common/putLine.js +1 -1
- package/src/common/putText.js +5 -4
- package/src/main.js +140 -19
- package/assets/fonts/Vazirmatn-Regular.woff2 +0 -0
- package/assets/styles-test.css +0 -86
- package/assets/styles.css +0 -86
- package/src/Form/Reflex.js +0 -145
- package/src/Form/Speech.js +0 -121
- package/src/Form/globalinfo.js +0 -68
@@ -0,0 +1,76 @@
|
|
1
|
+
const units = {
|
2
|
+
name: 'Tympanogram',
|
3
|
+
margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
|
4
|
+
|
5
|
+
// واحد ویوباکس - بدون واحد
|
6
|
+
vbWidth: 100, // برای اینکه ضخامت خطوط تغییری ناهنجار نکند این ثابت میماند
|
7
|
+
vbHeight: 60, // این به نسبت تغییر میکند
|
8
|
+
|
9
|
+
// واحد پیکسل، میلیمتر، ...
|
10
|
+
// اگر واحد پایینی توسط بیرون تغییر کرد واحدهای بالایی باید با نسبت پایینی تغییر کنند
|
11
|
+
width: 100,
|
12
|
+
height: 60,
|
13
|
+
|
14
|
+
// این فاصله خطوط محورهای بالا و چپ ادیوگرام از لبه ها هست
|
15
|
+
chartPadding: { left: 40, top: 40, right: 30, bottom: 20 },
|
16
|
+
symbolDims: { width: 55, height: 55 },
|
17
|
+
symbolsChart: {
|
18
|
+
width: 240, height: 60
|
19
|
+
},
|
20
|
+
// virtual frequency
|
21
|
+
mainFrequencies: [125, 250, 500, 1000, 2000, 4000, 8000],
|
22
|
+
|
23
|
+
intensity: { min: -20, max: 130, step: 10 },
|
24
|
+
|
25
|
+
styles: {
|
26
|
+
pressure: `
|
27
|
+
user-select: none;
|
28
|
+
direction: ltr !important;
|
29
|
+
font-family: Vazir;
|
30
|
+
font-size: 3;
|
31
|
+
text-anchor: middle;
|
32
|
+
dominant-baseline: hanging;
|
33
|
+
`,
|
34
|
+
caption: `
|
35
|
+
user-select: none;
|
36
|
+
direction: ltr !important;
|
37
|
+
font-family: Vazir;
|
38
|
+
font-size: 3;
|
39
|
+
text-anchor: middle;
|
40
|
+
dominant-baseline: middle;
|
41
|
+
`,
|
42
|
+
label: `
|
43
|
+
user-select: none;
|
44
|
+
direction: ltr !important;
|
45
|
+
font-family: Vazir;
|
46
|
+
font-size: 1mm;
|
47
|
+
text-anchor: start;
|
48
|
+
dominant-baseline: middle;
|
49
|
+
`,
|
50
|
+
type: `
|
51
|
+
user-select: none;
|
52
|
+
direction: ltr !important;
|
53
|
+
font-family: Vazir;
|
54
|
+
font-size: 1mm;
|
55
|
+
font-weight: bold;
|
56
|
+
text-anchor: start;
|
57
|
+
dominant-baseline: middle;
|
58
|
+
`,
|
59
|
+
compliance: `
|
60
|
+
user-select: none;
|
61
|
+
direction: ltr !important;
|
62
|
+
font-family: Vazir;
|
63
|
+
font-size: 0.7mm;
|
64
|
+
text-anchor: end;
|
65
|
+
dominant-baseline: middle;
|
66
|
+
`,
|
67
|
+
mainFreqline: `stroke: black; stroke-width: 1;`,
|
68
|
+
semiOctavFreqline: `stroke: black; stroke-width: 1; stroke-dasharray: 4;`,
|
69
|
+
boldLine: 'stroke: black; stroke-width: 3;',
|
70
|
+
|
71
|
+
juncDashLine: `stroke-width: 1 ; stroke-opacity: 0.8; stroke-dasharray: 4;`,
|
72
|
+
juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
|
73
|
+
},
|
74
|
+
}
|
75
|
+
|
76
|
+
export default units;
|
@@ -1,17 +1,17 @@
|
|
1
1
|
const svgNS = "http://www.w3.org/2000/svg";
|
2
2
|
|
3
|
-
export default function
|
3
|
+
export default function putCell(
|
4
4
|
{
|
5
|
-
container, x, y, dx = 0, dy= 0 ,
|
5
|
+
container, x, y, dx = 0, dy= 0 , width, height, rx,
|
6
6
|
style = "fill: transparent; stroke: black; stroke-width: 0.2;",
|
7
7
|
}) {
|
8
8
|
let rect = document.createElementNS(svgNS, "rect");
|
9
|
-
rect.setAttribute("x", x -
|
10
|
-
rect.setAttribute("y", y -
|
9
|
+
rect.setAttribute("x", x - width / 2 + dx);
|
10
|
+
rect.setAttribute("y", y - height / 2 + dy);
|
11
11
|
rect.setAttribute("rx", rx);
|
12
12
|
|
13
|
-
rect.setAttribute("width",
|
14
|
-
rect.setAttribute("height",
|
13
|
+
rect.setAttribute("width", width);
|
14
|
+
rect.setAttribute("height", height);
|
15
15
|
rect.setAttribute("style", style);
|
16
16
|
container.appendChild(rect);
|
17
17
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
2
|
+
|
3
|
+
export default function putG({ container, viewBox, className, style }) {
|
4
|
+
const svg = document.createElementNS(svgNS, "g");
|
5
|
+
viewBox && svg.setAttribute("viewBox", viewBox);
|
6
|
+
style && svg.setAttribute("style", style);
|
7
|
+
className && svg.setAttribute("class", className);
|
8
|
+
container && container.appendChild(svg);
|
9
|
+
return svg;
|
10
|
+
}
|
package/src/common/putLine.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// تابع رسم خط
|
2
2
|
const svgNS = "http://www.w3.org/2000/svg";
|
3
3
|
|
4
|
-
export default function putLine({ container, x1, y1, x2, y2, style = 'stroke: black; stroke-width: 0.
|
4
|
+
export default function putLine({ container, x1, y1, x2, y2, style = 'stroke: black; stroke-width: 0.3;', name }) {
|
5
5
|
|
6
6
|
let line = document.createElementNS(svgNS, "line");
|
7
7
|
line.setAttribute("x1", x1);
|
package/src/common/putText.js
CHANGED
@@ -3,16 +3,17 @@ const svgNS = "http://www.w3.org/2000/svg";
|
|
3
3
|
// متن اسویجی
|
4
4
|
export default function putText(
|
5
5
|
{ container, value = '', x, y, id, dx = 0, dy = 0, style, name, className }) {
|
6
|
+
|
6
7
|
let text = document.createElementNS(svgNS, "text");
|
7
8
|
name && text.setAttribute("data-name", name)
|
8
9
|
className && text.setAttribute("class", className);
|
9
10
|
style && text.setAttribute("style", style);
|
10
|
-
// text.setAttribute("dominant-baseline", "middle"); // تراز عمودی
|
11
|
-
// text.setAttribute("fill", color);
|
12
11
|
text.setAttribute("x", x + dx);
|
13
12
|
text.setAttribute("y", y + dy);
|
14
|
-
|
15
|
-
text.innerHTML = value;
|
13
|
+
text.textContent = value;
|
16
14
|
container.appendChild(text);
|
17
15
|
return text;
|
18
16
|
}
|
17
|
+
|
18
|
+
|
19
|
+
|
package/src/main.js
CHANGED
@@ -2,37 +2,157 @@
|
|
2
2
|
import Audiogram from "./Audiogram/Audiogram.js"
|
3
3
|
import Forms from "./Form/Forms.js";
|
4
4
|
import { officeData, patientData } from "../assets/data/sampleData.js"
|
5
|
-
import
|
5
|
+
import template from "../assets/templates/template_combo.js";
|
6
|
+
import Tympanogram from "./Tympanogram/Tympanogram.js";
|
7
|
+
import Speech from "./Speech/Speech.js";
|
8
|
+
import Reflex from "./Reflex/Reflex.js";
|
9
|
+
import Box from "./Box/Box.js";
|
6
10
|
|
7
11
|
|
8
12
|
document.querySelector('#app').innerHTML = `
|
13
|
+
<div id="test"></div>
|
9
14
|
<div id="audiogram-div"></div>
|
10
15
|
<div id="forms-div"></div>
|
11
16
|
`;
|
12
17
|
|
13
|
-
const
|
18
|
+
const container = document.getElementById('test')
|
19
|
+
|
20
|
+
let dims = {
|
21
|
+
"name": "RSpeech",
|
22
|
+
"w": 100,
|
23
|
+
"h": 15,
|
24
|
+
"margin": {
|
25
|
+
"left": 2,
|
26
|
+
"top": 0,
|
27
|
+
"right": 12,
|
28
|
+
"bottom": 0
|
29
|
+
},
|
30
|
+
"display": "inline",
|
31
|
+
"stroke": true,
|
32
|
+
"width": 100 * 6,
|
33
|
+
"height": 20 * 6,
|
34
|
+
"labels": [
|
35
|
+
"SAT",
|
36
|
+
"SRT",
|
37
|
+
"MCL",
|
38
|
+
"UCL",
|
39
|
+
"SDS"
|
40
|
+
]
|
41
|
+
}
|
42
|
+
|
43
|
+
const RSpeech = new Speech({ container, side: 'R' })
|
44
|
+
RSpeech.draw({ dims })
|
45
|
+
RSpeech.update({ MCL: '55', SAT: '25', SDS: '98', UCL: '120', SRT: '30' })
|
46
|
+
|
47
|
+
dims = {
|
48
|
+
"name": "RTympanogram",
|
49
|
+
"w": 100,
|
50
|
+
"h": 60,
|
51
|
+
"margin": {
|
52
|
+
"left": 2,
|
53
|
+
"top": 0,
|
54
|
+
"right": 2,
|
55
|
+
"bottom": 0
|
56
|
+
},
|
57
|
+
"display": "inline",
|
58
|
+
"width": 100 * 6,
|
59
|
+
"height": 60 * 6
|
60
|
+
}
|
61
|
+
|
62
|
+
const RTympanogram = new Tympanogram({ container, side: 'R' })
|
63
|
+
RTympanogram.draw({ dims });
|
64
|
+
|
65
|
+
dims = {
|
66
|
+
"name": "RReflex",
|
67
|
+
"w": 100,
|
68
|
+
"h": 28,
|
69
|
+
"margin": {
|
70
|
+
"left": 2,
|
71
|
+
"top": 2,
|
72
|
+
"right": 2,
|
73
|
+
"bottom": 0
|
74
|
+
},
|
75
|
+
"display": "inline",
|
76
|
+
"width": 100 * 6,
|
77
|
+
"height": 30 * 6
|
78
|
+
}
|
79
|
+
|
80
|
+
const RReflex = new Reflex({ container, side: 'R' })
|
81
|
+
RReflex.draw({ dims });
|
82
|
+
|
83
|
+
dims = {
|
84
|
+
"name": "report",
|
85
|
+
"w": 200,
|
86
|
+
"h": 20,
|
87
|
+
"margin": {
|
88
|
+
"left": 1,
|
89
|
+
"top": 0,
|
90
|
+
"right": 1,
|
91
|
+
"bottom": 0
|
92
|
+
},
|
93
|
+
"display": "block",
|
94
|
+
"width": 198,
|
95
|
+
"height": 20,
|
96
|
+
"elements": [
|
97
|
+
{
|
98
|
+
"type": "text",
|
99
|
+
"x": 198,
|
100
|
+
"y": 5,
|
101
|
+
"value": "گزارش:"
|
102
|
+
}
|
103
|
+
],
|
104
|
+
"inputs": [
|
105
|
+
{
|
106
|
+
"name": "description",
|
107
|
+
"x": 186,
|
108
|
+
"y": 5
|
109
|
+
}
|
110
|
+
]
|
111
|
+
}
|
112
|
+
|
113
|
+
// const report = new Box({ container })
|
114
|
+
// report.draw({ dims });
|
115
|
+
|
116
|
+
dims = {
|
117
|
+
"blank": false,
|
118
|
+
"name": "RAudiogram",
|
119
|
+
"w": 100,
|
120
|
+
"h": 90,
|
121
|
+
"margin": {
|
122
|
+
"left": 1,
|
123
|
+
"top": 1,
|
124
|
+
"right": 1,
|
125
|
+
"bottom": 1
|
126
|
+
},
|
127
|
+
"display": "inline",
|
128
|
+
"borderBox": "display",
|
129
|
+
"width": 600,
|
130
|
+
"height": 600
|
131
|
+
}
|
132
|
+
|
133
|
+
const RAudiogram = new Audiogram({ container, side: 'R', dims })
|
134
|
+
// RAudiogram.update({
|
135
|
+
// data: {
|
136
|
+
// // R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
|
137
|
+
// R_AC: { 1000: 25, 500: 15, 750: 20, 250: 10, 6000: 35, 2000: 45 },
|
138
|
+
// R_AC_NR: { 1500: 85 },
|
139
|
+
// R_BC_M: { 2000: 25, 6000: 25 },
|
140
|
+
// R_BC_M_NR: { 3000: 85 },
|
141
|
+
// R_BC: { 1000: 20, 500: 10, 750: 15, 250: 5, 4000: 20 },
|
142
|
+
// },
|
143
|
+
// side: 'R',
|
144
|
+
// })
|
145
|
+
|
146
|
+
const forms = new Forms({ container: document.getElementById('forms-div'), templates: [template], mode: 'develop' });
|
14
147
|
forms.update({ officeData, patientData, sessionIndex: 0 })
|
15
148
|
|
149
|
+
|
150
|
+
|
151
|
+
|
16
152
|
/*
|
17
|
-
const
|
18
|
-
container: document.getElementById('audiogram-div'), side: 'R',
|
19
|
-
})
|
153
|
+
const LAudiogram = new Audiogram({ container: document.getElementById('audiogram-div'), side: 'L', })
|
20
154
|
|
21
|
-
const LAudiogram = new Audiogram({
|
22
|
-
container: document.getElementById('audiogram-div'), side: 'L',
|
23
|
-
})
|
24
155
|
|
25
|
-
RAudiogram.update({
|
26
|
-
data: {
|
27
|
-
// R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
|
28
|
-
R_AC: { 1000: 25, 500: 15, 750: 20, 250: 10, 6000: 35, 2000: 45 },
|
29
|
-
R_AC_NR: { 1500: 85 },
|
30
|
-
R_BC_M: { 2000: 25, 6000: 25 },
|
31
|
-
R_BC_M_NR: { 3000: 85 },
|
32
|
-
R_BC: { 1000: 20, 500: 10, 750: 15, 250: 5, 4000: 20 },
|
33
|
-
},
|
34
|
-
side: 'R',
|
35
|
-
})
|
36
156
|
|
37
157
|
LAudiogram.update({
|
38
158
|
data: {
|
@@ -48,3 +168,4 @@ LAudiogram.update({
|
|
48
168
|
|
49
169
|
|
50
170
|
|
171
|
+
|
Binary file
|
package/assets/styles-test.css
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
|
2
|
-
.header1 {
|
3
|
-
user-select: none;
|
4
|
-
/* direction: rtl; */
|
5
|
-
/* text-align: center; */
|
6
|
-
font-family: Vazir;
|
7
|
-
font-size: 1.6mm;
|
8
|
-
font-weight: bolder;
|
9
|
-
}
|
10
|
-
.header2 {
|
11
|
-
user-select: none;
|
12
|
-
direction: rtl;
|
13
|
-
/* text-align: center; */
|
14
|
-
text-anchor: middle;
|
15
|
-
/* font-family: sans-serif, Helvetica, Arial;*/
|
16
|
-
/* font-family: Verdana, Geneva, Tahoma, sans-serif; */
|
17
|
-
font-family: sans-serif !important;
|
18
|
-
font-family: 'Courier New', Courier, monospace;
|
19
|
-
font-size: 1.1mm;
|
20
|
-
font-weight: bold;
|
21
|
-
}
|
22
|
-
|
23
|
-
.header3 {
|
24
|
-
user-select: none;
|
25
|
-
/* direction: rtl; */
|
26
|
-
/* text-align: center; */
|
27
|
-
font-family: sans-serif !important;
|
28
|
-
|
29
|
-
/* font-family: Vazir; */
|
30
|
-
font-size: 1mm;
|
31
|
-
font-weight: bold;
|
32
|
-
}
|
33
|
-
.header4 {
|
34
|
-
user-select: none;
|
35
|
-
direction: rtl;
|
36
|
-
/* text-align: center; */
|
37
|
-
font-family: Vazir;
|
38
|
-
font-size: 1mm;
|
39
|
-
/* font-weight: bold; */
|
40
|
-
}
|
41
|
-
.tymp1 {
|
42
|
-
user-select: none;
|
43
|
-
direction: ltr !important;
|
44
|
-
/* text-align: center; */
|
45
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
46
|
-
font-size: 1mm;
|
47
|
-
/* font-weight: bold; */
|
48
|
-
}
|
49
|
-
|
50
|
-
.tymp2 {
|
51
|
-
user-select: none;
|
52
|
-
direction: ltr !important;
|
53
|
-
/* text-align: center; */
|
54
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
55
|
-
font-size: 0.8mm;
|
56
|
-
/* font-weight: bold; */
|
57
|
-
}
|
58
|
-
.mizoon {
|
59
|
-
display: table;
|
60
|
-
margin-right: auto;
|
61
|
-
margin-left: auto;
|
62
|
-
/* display: flex; */
|
63
|
-
/* justify-content: center; */
|
64
|
-
}
|
65
|
-
|
66
|
-
.symbol_square {
|
67
|
-
stroke-opacity: 100;
|
68
|
-
}
|
69
|
-
|
70
|
-
input {
|
71
|
-
display: block;
|
72
|
-
width: 60%;
|
73
|
-
border: 1px solid antiquewhite;
|
74
|
-
padding: 10px 10px;
|
75
|
-
margin: 10px auto 10px auto;
|
76
|
-
}
|
77
|
-
|
78
|
-
.header5 {
|
79
|
-
/* font: 1.5px Verdana, Helvetica, Arial, sans-serif; */
|
80
|
-
user-select: none;
|
81
|
-
direction: rtl;
|
82
|
-
text-align: right;
|
83
|
-
font-family: Vazir;
|
84
|
-
font-size: 0.9mm;
|
85
|
-
font-weight: bold;
|
86
|
-
}
|
package/assets/styles.css
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
|
2
|
-
.header1 {
|
3
|
-
user-select: none;
|
4
|
-
/* direction: rtl; */
|
5
|
-
/* text-align: center; */
|
6
|
-
font-family: Vazir;
|
7
|
-
font-size: 1.6mm;
|
8
|
-
font-weight: bolder;
|
9
|
-
}
|
10
|
-
.header2 {
|
11
|
-
user-select: none;
|
12
|
-
direction: rtl;
|
13
|
-
/* text-align: center; */
|
14
|
-
text-anchor: middle;
|
15
|
-
/* font-family: sans-serif, Helvetica, Arial;*/
|
16
|
-
/* font-family: Verdana, Geneva, Tahoma, sans-serif; */
|
17
|
-
font-family: sans-serif !important;
|
18
|
-
font-family: 'Courier New', Courier, monospace;
|
19
|
-
font-size: 1.1mm;
|
20
|
-
font-weight: bold;
|
21
|
-
}
|
22
|
-
|
23
|
-
.header3 {
|
24
|
-
user-select: none;
|
25
|
-
/* direction: rtl; */
|
26
|
-
/* text-align: center; */
|
27
|
-
font-family: sans-serif !important;
|
28
|
-
|
29
|
-
/* font-family: Vazir; */
|
30
|
-
font-size: 1mm;
|
31
|
-
font-weight: bold;
|
32
|
-
}
|
33
|
-
.header4 {
|
34
|
-
user-select: none;
|
35
|
-
direction: rtl;
|
36
|
-
/* text-align: center; */
|
37
|
-
font-family: Vazir;
|
38
|
-
font-size: 1mm;
|
39
|
-
/* font-weight: bold; */
|
40
|
-
}
|
41
|
-
.tymp1 {
|
42
|
-
user-select: none;
|
43
|
-
direction: ltr !important;
|
44
|
-
/* text-align: center; */
|
45
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
46
|
-
font-size: 1mm;
|
47
|
-
/* font-weight: bold; */
|
48
|
-
}
|
49
|
-
|
50
|
-
.tymp2 {
|
51
|
-
user-select: none;
|
52
|
-
direction: ltr !important;
|
53
|
-
/* text-align: center; */
|
54
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
55
|
-
font-size: 0.8mm;
|
56
|
-
/* font-weight: bold; */
|
57
|
-
}
|
58
|
-
.mizoon {
|
59
|
-
display: table;
|
60
|
-
margin-right: auto;
|
61
|
-
margin-left: auto;
|
62
|
-
/* display: flex; */
|
63
|
-
/* justify-content: center; */
|
64
|
-
}
|
65
|
-
|
66
|
-
.symbol_square {
|
67
|
-
stroke-opacity: 100;
|
68
|
-
}
|
69
|
-
|
70
|
-
input {
|
71
|
-
display: block;
|
72
|
-
width: 60%;
|
73
|
-
border: 1px solid antiquewhite;
|
74
|
-
padding: 10px 10px;
|
75
|
-
margin: 10px auto 10px auto;
|
76
|
-
}
|
77
|
-
|
78
|
-
.header5 {
|
79
|
-
/* font: 1.5px Verdana, Helvetica, Arial, sans-serif; */
|
80
|
-
user-select: none;
|
81
|
-
direction: rtl;
|
82
|
-
text-align: right;
|
83
|
-
font-family: Vazir;
|
84
|
-
font-size: 0.9mm;
|
85
|
-
font-weight: bold;
|
86
|
-
}
|
package/src/Form/Reflex.js
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
import putRect from "../common/putRect.js";
|
2
|
-
import putText from "../common/putText.js";
|
3
|
-
|
4
|
-
const svgNS = "http://www.w3.org/2000/svg";
|
5
|
-
|
6
|
-
export default class Reflex {
|
7
|
-
constructor({ container, side }) {
|
8
|
-
this.container = container;
|
9
|
-
this.side = side; // این برای تعیین رنگ راست و چپ استفاده میشود
|
10
|
-
}
|
11
|
-
|
12
|
-
draw({ dims }) {
|
13
|
-
|
14
|
-
let width = dims.width;
|
15
|
-
let height = dims.height;
|
16
|
-
let x = dims.margin.left;
|
17
|
-
let y = dims.margin.top;
|
18
|
-
let style;
|
19
|
-
|
20
|
-
// x = 10
|
21
|
-
// y=1
|
22
|
-
// width= 80
|
23
|
-
// height = 24
|
24
|
-
|
25
|
-
const svg = document.createElementNS(svgNS, "svg");
|
26
|
-
svg.setAttribute("x", x);
|
27
|
-
svg.setAttribute("y", y);
|
28
|
-
svg.setAttribute("width", width);
|
29
|
-
svg.setAttribute("height", height);
|
30
|
-
svg.setAttribute("class", "reflex");
|
31
|
-
|
32
|
-
let lable = ["", "500", "1000", "2000", "4000"]; // مقادیر برچسبهای سطر اول
|
33
|
-
// جدولی با ۳ سطر و ۵ ستون
|
34
|
-
let cw1 = width / 5; // پهنای خانههای سطر اول
|
35
|
-
let ch1 = height / 3; // ارتفاع خانههای سطر اول
|
36
|
-
let ch2 = height / 3; // ارتفاع خانههای سطر دوم
|
37
|
-
|
38
|
-
// چاپ برچسبهای سطر اول
|
39
|
-
style = `
|
40
|
-
user-select: none;
|
41
|
-
direction: ltr !important;
|
42
|
-
/* text-align: center; */
|
43
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
44
|
-
font-size: 1mm;
|
45
|
-
font-weight: bold;
|
46
|
-
text-anchor: middle; /*تراز افقی*/
|
47
|
-
dominant-baseline: middle; /* تراز عمودی*/
|
48
|
-
`;
|
49
|
-
lable.forEach((value, i) => {
|
50
|
-
if (value != "") {
|
51
|
-
let x = cw1 / 2 + cw1 * i;
|
52
|
-
let y = ch1 / 2;
|
53
|
-
// putText(value, x, y, "", "middle", "middle"); // با استایل تراز عمودی پایین نسبت به خط پایه
|
54
|
-
putText({ container: svg, value, x, y, style })
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
// مقادیر برچسبهای ستون اول
|
59
|
-
style = `
|
60
|
-
user-select: none;
|
61
|
-
direction: ltr !important;
|
62
|
-
/* text-align: center; */
|
63
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
64
|
-
font-size: 1mm;
|
65
|
-
font-weight: bold;
|
66
|
-
text-anchor: end; /*تراز افقی*/
|
67
|
-
dominant-baseline: middle; /* تراز عمودی*/
|
68
|
-
`;
|
69
|
-
lable = ["Freq", "IPSI", "CONTRA"];
|
70
|
-
// چاپ برچسبهای ستون اول
|
71
|
-
putText({ container: svg, value: "Freq", x: cw1, y: ch1 / 2, style: style })
|
72
|
-
putText({ container: svg, value: "IPSI", x: cw1, y: ch1 * 3 / 2, style: style })
|
73
|
-
putText({ container: svg, value: "CONTRA", x: cw1, y: ch1 * 5 / 2, style: style })
|
74
|
-
|
75
|
-
//چاپ ده باکس سطر دوم و سوم
|
76
|
-
for (let j = 1; j <= 2; j++) {
|
77
|
-
for (let i = 1; i <= 4; i++) {
|
78
|
-
let x = cw1 / 2 + cw1 * i;
|
79
|
-
let y = ch1 * j + ch2 / 2;
|
80
|
-
let bw = cw1 * 0.8; // پهنای هر باکس
|
81
|
-
let bh = ch2 * 0.7; // ارتفاع هر باکس
|
82
|
-
//رسم باکس با مختصات مرکز باکس
|
83
|
-
putBox(x, y, bw, bh);
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
style = `
|
88
|
-
user-select: none;
|
89
|
-
direction: ltr !important;
|
90
|
-
/* text-align: center; */
|
91
|
-
font-family: Arial, Helvetica, sans-serif !important;
|
92
|
-
font-size: 1mm;
|
93
|
-
text-anchor: middle; /*تراز افقی*/
|
94
|
-
dominant-baseline: middle; /* تراز عمودی*/
|
95
|
-
`;
|
96
|
-
// اضافه کردن رنگ قرمز یا آبی به استایل بر اساس جهت
|
97
|
-
style += (this.side === 'R') ? 'fill: red;' : 'fill: blue;';
|
98
|
-
|
99
|
-
let names = ["IPSI_500", "IPSI_1000", "IPSI_2000", "IPSI_4000"];
|
100
|
-
for (let index = 0; index < 4; index++) {
|
101
|
-
x = cw1 / 2 + cw1 * (index + 1);
|
102
|
-
y = ch1 + ch2 / 2;
|
103
|
-
putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
|
104
|
-
}
|
105
|
-
|
106
|
-
// المنتهای تکست خالی با آیدی یکتا در سطر سوم
|
107
|
-
// آرایه نام آیدی یکتا برای المنت تکست مقادیر برای استفاده تابع آپدیت
|
108
|
-
names = ["CONTRA_500", "CONTRA_1000", "CONTRA_2000", "CONTRA_4000"];
|
109
|
-
|
110
|
-
for (let index = 0; index < 4; index++) {
|
111
|
-
// const idValue = idValues[index];
|
112
|
-
x = cw1 / 2 + cw1 * (index + 1);
|
113
|
-
y = ch1 * 2 + ch2 / 2;
|
114
|
-
putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
|
115
|
-
}
|
116
|
-
// مربع احاطهکننده کل جدول برای راهنمای توسعه و دریافت رویداد کلیک روی فرم
|
117
|
-
style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
|
118
|
-
putRect({ container: svg, x: 0, y: 0, width, height, style, name: dims.name })
|
119
|
-
this.container.appendChild(svg);
|
120
|
-
this.chart = svg;
|
121
|
-
// return svg;
|
122
|
-
|
123
|
-
// توابع داخلی مورد نیاز
|
124
|
-
function putBox(x, y, w, h) {
|
125
|
-
let rect = document.createElementNS(svgNS, "rect");
|
126
|
-
rect.setAttribute("x", x - w / 2);
|
127
|
-
rect.setAttribute("y", y - h / 2);
|
128
|
-
rect.setAttribute("width", w);
|
129
|
-
rect.setAttribute("height", h);
|
130
|
-
rect.setAttribute("rx", 1.5)
|
131
|
-
rect.setAttribute("style", "fill: transparent; stroke: black; stroke-width: 0.2;");
|
132
|
-
svg.appendChild(rect);
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
// جایگذاری داده های رفلکس
|
137
|
-
update(data) {
|
138
|
-
|
139
|
-
for (const key in data) {
|
140
|
-
for (const freq in data[key]) {
|
141
|
-
this.chart.querySelector(`text[data-name=${key}_${freq}]`).innerHTML = data?.[key]?.[freq] || "";
|
142
|
-
}
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|