hayun-vite 0.13.0 → 0.15.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.
@@ -12,25 +12,31 @@ export default class Tympanogram {
12
12
  this.draw({ dims })
13
13
  }
14
14
 
15
- draw({ dims, extraCompliance = false }) {
16
- let width = dims.width;
17
- let height = dims.height;
15
+ draw({ dims }) {
16
+ // پاک کردن چارت قبلی اگر وجود دارد
17
+ this.chart && this.chart.remove()
18
+
19
+ // داده‌های یونتیت خوانده میشود و بعد داده‌های دیمز به آن اضافه می‌‌شودکه می‌تواند جایگزین داده‌های قبلی یونیتز شود
20
+ dims = { ...units, ...dims }
21
+
22
+ let { width, height } = dims
18
23
  let x = dims.margin.left;
19
24
  let y = dims.margin.top;
20
- let style;
25
+ const { extraCompliance, compensated } = dims
21
26
 
22
27
  const { pressure, padding, styles } = units
23
28
 
24
29
  const compliance = extraCompliance ? units.compliance.extra : units.compliance.normal
25
30
 
26
-
27
31
  let { vbWidth, vbHeight } = units;
28
32
 
29
33
  // کل چارت
34
+ let style
30
35
  style = styles.svg
31
36
  vbHeight = (vbWidth * height) / width // متناسب سازی ارتفاع ویباکس با پهنا و ارتفاع ورودی
32
37
  const viewBox = [-padding.left, -padding.top, vbWidth, vbHeight].join(' ')
33
38
  const svg = putSVG({ x, y, width, height, viewBox, style })
39
+ this.chart = svg;
34
40
  // این خط شد دو خط کد طلایی که مشکل سایز فونت در دیسپلی و کاغذ رو حل کرد
35
41
  width = vbWidth; // ثابت می‌ماند همیشه
36
42
  height = vbHeight // با نسبت پهنا و ارتفاع ورودی تغییر میکند
@@ -45,7 +51,10 @@ export default class Tympanogram {
45
51
  mm: height - (padding.top + padding.bottom)
46
52
  }
47
53
 
48
- this.chartInfo = { pressure, compliance, padding, pressureAxiosLength, complianceAxiosLength }
54
+ this.chartInfo = {
55
+ pressure, compliance, padding,
56
+ pressureAxiosLength, complianceAxiosLength, compensated,
57
+ }
49
58
 
50
59
  // point({ container: svg, x: getX(pressure.min), y: getY(compliance.max), color: 'red' })
51
60
  // point({ container: svg, x: getX(pressure.max), y: getY(compliance.min), color: 'green' })
@@ -175,7 +184,7 @@ export default class Tympanogram {
175
184
  putText({
176
185
  container: svg, value: c.toFixed(1),
177
186
  x, y: getY(c), dx: -1,
178
- style: style,
187
+ style,
179
188
  });
180
189
  }
181
190
 
@@ -193,8 +202,9 @@ export default class Tympanogram {
193
202
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
194
203
  // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
195
204
  putRect({ container: svg, x: -padding.left, y: -padding.top, width, height, name: dims.name, style })
196
- this.chart = svg;
197
205
  this.container.appendChild(svg);
206
+ // اگر آبجکت از قبل دیتایی دارد اون رو آپدیت کن
207
+ this.data && this.update(this.data)
198
208
 
199
209
  // بلاک توابع داخلی مورد نیاز تابع اصلی
200
210
  // توابع تبدیل فشار و کامپلیانس به مختصات میلیمتر
@@ -229,14 +239,11 @@ export default class Tympanogram {
229
239
  }
230
240
 
231
241
  update(data) {
232
- let { ECV, SC, MEP, G, extraCompliance } = data
233
-
234
- // اگر اکسترا کامپلیانس بود چارت دوباره باید رسم شود و چارت قبلی پاک شود
235
- if (extraCompliance) {
236
- this.chart.remove()
237
- this.draw({ dims: this.dims, extraCompliance })
238
- }
242
+ this.data = data
243
+ console.log(data);
239
244
 
245
+ let { ECV, SC, MEP, G } = data
246
+
240
247
  // تبدبل اعداد رشته ای به عدد با دو رقم اعشاری
241
248
  ECV && (ECV = (+ECV).toFixed(2));
242
249
  SC && (SC = (+SC).toFixed(2));
@@ -256,33 +263,38 @@ export default class Tympanogram {
256
263
 
257
264
  // توابع داخلی
258
265
  drawCurve(data) {
259
- let { Type, ECV, SC, MEP, G, expanded } = data
260
-
266
+ let { Type, ECV, SC, MEP, G, expanded, cp, cpp } = data
261
267
 
262
268
  // Ensure to Convert to Numbers //
263
- SC = +SC;
264
- ECV = +ECV;
265
- MEP = +MEP;
266
- G = +G;
269
+ SC = +SC
270
+ ECV = +ECV
271
+ MEP = +MEP
272
+ G = +G
273
+ cp = +cp
274
+ cpp = +cpp
267
275
 
268
276
  // اگر این مقادیر وجود نداشته باشه مقدار صفر میدیم بهشون که خطا در رسم منحنی نخوریم
269
277
  SC || (SC = 0)
270
278
  MEP || (MEP = 0)
271
279
 
272
-
273
280
  const container = this.chart
274
- const { pressure, compliance, pressureAxiosLength, complianceAxiosLength } = this.chartInfo;
281
+ const { pressure, compliance, pressureAxiosLength, complianceAxiosLength, compensated } = this.chartInfo;
282
+
283
+ let cmp = 0 // for non-compensated
284
+ compensated && (cmp = ECV)
275
285
 
276
286
  // مقداردهی دستی برای تست شکل منحنی
277
287
  // data.SC = 0.5;
278
288
  // data.MEP = -75;
279
289
  // با توجه به اندازه اس ‌سی میشه برای مقادیر زیر یک سری رل گذاشت با منحنی قشنگ تر باشد
280
- let cp = 70 // جابجایی نقطه کنترل منحنی های راست و چپ روی محور افقی
290
+ // let cp = 70 // جابجایی نقطه کنترل منحنی های راست و چپ روی محور افقی
291
+ !cp && (cp = 70)
281
292
  // let k = 0.5; // width and height change [0, 1]
282
- let cpp = 5 //جابجایی نقطه کنترل قله ها روی محور افقی
293
+ !cpp && (cpp = 5) //جابجایی نقطه کنترل قله ها روی محور افقی
283
294
  // رل‌هایی برای تغییر مقادیر بالا برای زیبایی بیشتر منحنی در نقطه قله
284
295
  // (data.SC <= 0.30)? k=0
285
- let k = (SC > 0.30) ? 0.5 : 0.1 // width and height change [0, 1]
296
+ let k
297
+ k = (SC > 0.30) ? 0.5 : 0.1 // width and height change [0, 1]
286
298
  k = (SC > 1.0) ? 0.2 : k
287
299
  // k = (data.SC < 1.0) ? 0 : k;
288
300
 
@@ -299,24 +311,24 @@ export default class Tympanogram {
299
311
 
300
312
  const curve = {
301
313
  R: {
302
- P1: { p: RV.max, c: 0 },
303
- P2: { p: MEP + pw, c: SC - ph },
304
- C: { p: MEP + cp, c: 0 }
314
+ P1: { p: RV.max, c: cmp },
315
+ P2: { p: MEP + pw, c: cmp + SC - ph },
316
+ C: { p: MEP + cp, c: cmp }
305
317
  },
306
318
  RM: {
307
319
  P1: {}, // Define later
308
- P2: { p: MEP, c: SC },
309
- C: { p: MEP + cpp, c: SC }
320
+ P2: { p: MEP, c: cmp + SC },
321
+ C: { p: MEP + cpp, c: cmp + SC }
310
322
  },
311
323
  LM: {
312
324
  P1: {}, // Define later
313
- P2: { p: MEP - pw, c: SC - ph },
314
- C: { p: MEP - cpp, c: SC }
325
+ P2: { p: MEP - pw, c: cmp + SC - ph },
326
+ C: { p: MEP - cpp, c: cmp + SC }
315
327
  },
316
328
  L: {
317
329
  P1: {}, // Define later
318
- P2: { p: RV.min, c: 0 },
319
- C: { p: MEP - cp, c: 0 }
330
+ P2: { p: RV.min, c: cmp },
331
+ C: { p: MEP - cp, c: cmp }
320
332
  }
321
333
  }
322
334
 
@@ -2,11 +2,23 @@ import Tympanogram from "./Tympanogram";
2
2
 
3
3
  document.querySelector('#app').innerHTML = `
4
4
  <div id="test"></div>
5
+ <p>Curve settings:</p>
6
+ <div>
7
+ <input type="range" id="cp" name="cp" min="10" max="150" value="70" step="5" />
8
+ <label for="cp">cp</label>
9
+ <input type="range" id="cpp" name="cpp" min="1" max="10" value="5" step="1" />
10
+ <label for="cpp">cpp</label>
11
+ <div>
12
+ <input type="checkbox" name="extra-sc" id="extra-sc">
13
+ <label for="extra-sc">Extra SC</label>
14
+ </div>
15
+ <div>
16
+ <input type="checkbox" name="compensated" id="compensated">
17
+ <label for="compensated">Compensated</label>
18
+ </div>
19
+ </div>
5
20
  `;
6
-
7
- const container = document.getElementById('test')
8
-
9
- const dims = {
21
+ let dims = {
10
22
  "name": "RTympanogram",
11
23
  "w": 100,
12
24
  "h": 60,
@@ -18,17 +30,56 @@ const dims = {
18
30
  },
19
31
  "display": "inline",
20
32
  "width": 100 * 12,
21
- "height": 60 * 12
33
+ "height": 60 * 12,
22
34
  }
23
- const RTympanogram = new Tympanogram({ container, dims, side: 'R' })
24
- RTympanogram.update({
35
+ let data = {
25
36
  Type: "An",
26
- ECV: '3',
27
- SC: '1.5',
28
- MEP: '-150',
37
+ ECV: '1.30',
38
+ SC: '0.80',
39
+ MEP: '-130',
29
40
  G: 0.2,
30
41
  expanded: false, // by default is false for expand pressure from -600 to +400
31
- // extraCompliance: true // by default is false (0 - 3) and true is: (0 - 6)
32
42
 
43
+ }
44
+ let cp = 70, cpp = 5, extraCompliance, compensated
45
+
46
+ document.querySelector("#compensated").addEventListener("input", e => {
47
+ compensated = e.target.checked
48
+ console.log(e.target.checked);
49
+ dims = { ...dims, compensated }
50
+ RTympanogram.draw({ dims })
51
+
52
+ })
53
+
54
+ document.querySelector("#extra-sc").addEventListener("input", e => {
55
+ extraCompliance = e.target.checked
56
+ console.log(e.target.checked);
57
+ dims = { ...dims, extraCompliance }
58
+ RTympanogram.draw({ dims })
59
+
60
+ })
61
+
62
+ document.querySelector("#cp")
63
+ .addEventListener("input", e => {
64
+ cp = e.target.value
65
+ console.log(cp);
66
+ data = {...data, cp}
67
+
68
+ RTympanogram.update(data)
69
+ })
70
+
71
+
72
+ document.querySelector("#cpp")
73
+ .addEventListener("input", e => {
74
+ cpp = e.target.value
75
+ console.log(cpp);
76
+ data = {...data, cpp}
77
+
78
+ RTympanogram.update(data)
79
+ })
80
+
81
+ const container = document.getElementById('test')
82
+
83
+ const RTympanogram = new Tympanogram({ container, dims, side: 'R' })
84
+ RTympanogram.update(data)
33
85
 
34
- })
@@ -17,7 +17,8 @@ const units = {
17
17
  extra: { min: -0.50, max: 6, step: 0.50 }
18
18
  },
19
19
  padding: { right: 5, left: 8, top: 7, bottom: 14 },
20
-
20
+ extraCompliance: false, // default is false (0-3) | true (0-6)
21
+ compensated: false, // default is false | true
21
22
 
22
23
  styles: {
23
24
  svg: 'user-select: none; direction: ltr !important; font-family: Vazir;',
@@ -0,0 +1,31 @@
1
+ import putLine from "./putLine";
2
+
3
+ export default function putGrid({ container }) {
4
+ const {x, y, width, height} = container.viewBox.baseVal
5
+ console.log(x, y, width, height);
6
+
7
+ const cord = { xStart: x, yStart: y, xEnd: width + x, yEnd: height + y, xStep: 1, yStep: 1 }
8
+ let { xStart, yStart, xEnd, yEnd, xStep, yStep } = cord
9
+
10
+ // رسم خطوط افقی
11
+ let style = 'stroke: blue; stroke-width: 0.05 ; stroke-opacity: 0.8; stroke-dasharray: 0.2;'
12
+ let x1 = xStart
13
+ let y1
14
+
15
+ let x2 = xEnd
16
+ let y2
17
+
18
+ for (let y1 = yStart; y1 <= yEnd; y1 += yStep) {
19
+ y2 = y1
20
+ putLine({ container, x1, y1, x2, y2, style, name: 'grid' })
21
+ }
22
+
23
+ // رسم خطوط عمودی
24
+ y1 = yStart
25
+ for (x1 = xStart; x1 <= xEnd; x1 += xStep) {
26
+ const x2 = x1
27
+ putLine({ container, x1, y1, x2, y2, style, name: 'grid' })
28
+ }
29
+
30
+
31
+ }
package/src/main.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import Audiogram from "./Audiogram/Audiogram.js"
3
3
  import Forms from "./Forms/Forms.js";
4
4
  import { officeData, patientData } from "../assets/data/sampleData.js"
5
- import template from "../assets/templates/template_combo.js";
5
+ import template from "../assets/templates/templCombo.js";
6
6
  import Tympanogram from "./Tympanogram/Tympanogram.js";
7
7
  import Speech from "./Speech/Speech.js";
8
8
  import Reflex from "./Reflex/Reflex.js";
File without changes