hayun-vite 0.10.0 → 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.
Files changed (59) hide show
  1. package/assets/data/sampleData.js +10 -2
  2. package/assets/templates/mainTemplate.js +128 -0
  3. package/assets/templates/template_combo.js +50 -45
  4. package/package.json +1 -1
  5. package/public/fonts/Vazir-Black-UI.eot +0 -0
  6. package/public/fonts/Vazir-Black-UI.woff +0 -0
  7. package/public/fonts/Vazir-Black-UI.woff2 +0 -0
  8. package/public/fonts/Vazir-Bold-UI.eot +0 -0
  9. package/public/fonts/Vazir-Bold-UI.woff +0 -0
  10. package/public/fonts/Vazir-Bold-UI.woff2 +0 -0
  11. package/public/fonts/Vazir-Light-UI.eot +0 -0
  12. package/public/fonts/Vazir-Light-UI.woff +0 -0
  13. package/public/fonts/Vazir-Light-UI.woff2 +0 -0
  14. package/public/fonts/Vazir-Medium-UI.eot +0 -0
  15. package/public/fonts/Vazir-Medium-UI.woff +0 -0
  16. package/public/fonts/Vazir-Medium-UI.woff2 +0 -0
  17. package/public/fonts/Vazir-Regular-UI.eot +0 -0
  18. package/public/fonts/Vazir-Regular-UI.woff +0 -0
  19. package/public/fonts/Vazir-Regular-UI.woff2 +0 -0
  20. package/public/fonts/Vazir-Thin-UI.eot +0 -0
  21. package/public/fonts/Vazir-Thin-UI.woff +0 -0
  22. package/public/fonts/Vazir-Thin-UI.woff2 +0 -0
  23. package/src/Audiogram/Audiogram.js +43 -21
  24. package/src/Audiogram/Audiogram_100.js +499 -0
  25. package/src/Audiogram/Audiogram_box.js +483 -0
  26. package/src/Audiogram/dims.js +4 -80
  27. package/src/Audiogram/dims_100.js +51 -0
  28. package/src/Audiogram/dims_box.js +125 -0
  29. package/src/{Form → Box}/Box.js +26 -3
  30. package/src/Form/Form.js +8 -8
  31. package/src/Form/Form_N.js +194 -0
  32. package/src/Form/Forms.js +0 -2
  33. package/src/Form/Sections.js +0 -6
  34. package/src/Form/Sections_N.js +66 -0
  35. package/src/Form/printForm.js +57 -5
  36. package/src/{Form → Header}/Header.js +2 -5
  37. package/src/Header/Header_N.js +72 -0
  38. package/src/MultiText/MultiText.js +37 -0
  39. package/src/{Form/Reflex_N.js → Reflex/Reflex.js} +15 -3
  40. package/src/Reflex/units.js +65 -0
  41. package/src/{Form/Speech_N.js → Speech/Speech.js} +45 -28
  42. package/src/Speech/Speech_N.js +125 -0
  43. package/src/Speech/units.js +31 -0
  44. package/src/{Form → Tympanogram}/Tympanogram.js +37 -68
  45. package/src/Tympanogram/units.js +76 -0
  46. package/src/common/{putTextBox.js → putCell.js} +6 -6
  47. package/src/common/putG.js +10 -0
  48. package/src/common/putLine.js +1 -1
  49. package/src/common/putText.js +5 -4
  50. package/src/main.js +140 -19
  51. package/src/styles.css +63 -3
  52. package/assets/fonts/Vazirmatn-Regular.woff2 +0 -0
  53. package/assets/styles-test.css +0 -90
  54. package/assets/styles.css +0 -90
  55. package/src/Form/Reflex.js +0 -145
  56. package/src/Form/Speech.js +0 -121
  57. package/src/Form/formStyles.css +0 -117
  58. package/src/Form/globalinfo.js +0 -68
  59. package/src/note.html +0 -64
@@ -0,0 +1,483 @@
1
+ import putLine from "../common/putLine.js";
2
+ import putPoint from "../common/putPoint.js";
3
+ import putRect from "../common/putRect.js";
4
+ import putSVG from "../common/putSVG.js";
5
+ import putText from "../common/putText.js";
6
+ import getAllSymbolsSVG from "../Symbol/getAllSymbolsSVG.js";
7
+ import mainDims from './dims_N.js';
8
+
9
+ export default class Audiogram {
10
+ constructor({ box, side, events = true }) {
11
+
12
+ // this.container = container;
13
+
14
+ this.events = events;
15
+ this.side = side;
16
+ this.data = {};
17
+ const symbols = getAllSymbolsSVG();
18
+ this.symbols = symbols;
19
+ this.draw({ box });
20
+ events && this.addEvents();
21
+ }
22
+
23
+ draw({ box }) {
24
+
25
+ const { container, width, height, margin, elements, name } = box
26
+
27
+ // this.dims = {}
28
+ // Object.assign(this.dims, mainDims)
29
+
30
+ // اضافه کردن ابعاد جایگزین و یا اختصاصی دیگر به آبجکت ابعاد
31
+ // dims && Object.assign(this.dims, dims);
32
+
33
+
34
+ // const [container, dims] = [this.container, this.dims]
35
+ let
36
+ {
37
+ vbWidth, vbHeight, chartPadding, symbolDims, vf, vfArray,
38
+ vfToF, fToVf, intensity, styles, frequencies
39
+ }
40
+ = mainDims;
41
+ // متناسب سازی مقدار ارتفاع ویوباکس بر حسب نسبت طول و عرض پیکسلی
42
+ const
43
+ kpx = height / width,
44
+ kvb = vbWidth / vbHeight;
45
+
46
+ vbHeight = vbHeight * kpx * kvb;
47
+
48
+ let x = margin.left
49
+ let y = margin.top
50
+
51
+ this.symbolDims = symbolDims;
52
+ this.vf = vf;
53
+ this.vfArray = vfArray;
54
+ this.fToVf = fToVf; // index of coresponding frequency
55
+ this.vfToF = vfToF;
56
+ this.intensity = intensity;
57
+ this.styles = styles;
58
+ this.chartPadding = chartPadding;
59
+
60
+ let style;
61
+ const xArea = { min: chartPadding.left, max: vbWidth - (chartPadding.right) }
62
+ this.xArea = xArea
63
+ const yArea = { min: chartPadding.top, max: vbHeight - (chartPadding.bottom) }
64
+
65
+ const xAxisLength = {
66
+ vb: vbWidth - (chartPadding.left + chartPadding.right),
67
+ hzi: vf.max - vf.min // 0, 1, 2, ... instead 125, ...
68
+ }
69
+ this.xAxisLength = xAxisLength
70
+
71
+ const yAxisLength = {
72
+ vb: vbHeight - (chartPadding.top + chartPadding.bottom),
73
+ db: intensity.max - intensity.min
74
+ }
75
+ this.yAxisLength = yAxisLength
76
+
77
+ // Main SVG for Audiogram
78
+ const viewBox = [-chartPadding.left, -chartPadding.top, vbWidth, vbHeight]
79
+ const svg = putSVG({ container, x, y, width, height, viewBox })
80
+ this.svg = svg; // کل نودی که به کانتینر اپند میشه
81
+
82
+ // برای فرم‌های پیش چاپ نشده
83
+ // if (!dims.blank) {
84
+ // محدوده مختصات خطوط جدول
85
+ const chartArea = putRect({
86
+ container: svg,
87
+ x: this.getX(vf.min), y: this.getY(intensity.min),
88
+ width: xAxisLength.vb, height: yAxisLength.vb,
89
+ style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
90
+ })
91
+ // رسم خطوط افقی از بالا به پایین
92
+ let x1 = this.getX(vf.min);
93
+ let x2 = this.getX(vf.max);
94
+ for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
95
+ const y1 = this.getY(i)
96
+ const y2 = y1;
97
+ style = (i === 0) ? styles.boldLine : styles.line;
98
+ putLine({ container: svg, x1, y1, x2, y2, style })
99
+ }
100
+
101
+ // رسم خطوط عمودی از چپ به راست
102
+ let y1 = this.getY(intensity.min)
103
+ let y2 = this.getY(intensity.max)
104
+ frequencies.forEach(item => {
105
+ const x1 = this.getX(item.vf)
106
+ const x2 = x1
107
+ style = (item.semiOctav) ? styles.semiOctavFreqline : styles.mainFreqline;
108
+ (item.f === 1000) && (style = styles.boldLine);
109
+ putLine({ container: svg, x1, y1, x2, y2, style })
110
+ })
111
+ // برچسب های اعداد فرکانس
112
+ style = styles.frequency
113
+ const y = this.getY(-25)
114
+ frequencies.forEach(item => {
115
+ const value = item.f
116
+ const x = this.getX(item.vf)
117
+ !item.semiOctav && item.f != 125 && item.f != 16000 &&
118
+ putText({ container: svg, value, x, y, style });
119
+ })
120
+
121
+ // رسم اعداد شدت محور عمودی
122
+ style = styles.intensity
123
+ const x = this.getX(-0.1)
124
+ for (let i = -10; i <= 120; i += 10) {
125
+ const y = this.getY(i)
126
+ const value = i
127
+ putText({ container: svg, x, y, value, style })
128
+ }
129
+ // }
130
+ // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
131
+ // این مربع مرزی را آخرین ایجاد میکنیم تا بالاترین لایه باشد و روی ریودادها درست عمل کند
132
+ const borderRect = putRect({
133
+ container: svg, x: -chartPadding.left, y: -chartPadding.top,
134
+ width: vbWidth, height: vbHeight, name: '',
135
+ style: 'fill: transparent; stroke: transparent;',
136
+ });
137
+ this.borderRect = borderRect;
138
+
139
+ const lastCordinate = { f: 125, i: -20 }
140
+ this.lastCordinate = lastCordinate
141
+ const currentCordinate = { f: 125, i: -20 }
142
+ this.currentCordinate = currentCordinate
143
+
144
+ const chartArea = putRect({
145
+ container: svg, x: 0, y: 0,
146
+ width: xAxisLength.vb, height: yAxisLength.vb,
147
+ style: 'fill: transparent; stroke: transparent;',
148
+ name: 'RAudiogram',
149
+ });
150
+
151
+ this.chartArea = chartArea
152
+ this.events && this.drawSymbolsChart();
153
+ container.appendChild(svg);
154
+ }
155
+
156
+ addEvents() {
157
+ // برای قابل فوکوس کردن چارت ادیوگرام و دریافت رویدادهای صفحه کلید
158
+ this.svg.setAttribute('tabindex', 1)
159
+ this.svg.focus({ focusVisible: true });
160
+
161
+ this.svg.style.outline = 'none';
162
+
163
+
164
+ // نقطه راهنما
165
+ const pointer = putPoint({ container: this.svg, x: 0, y: 0, r: 4, color: 'black' });
166
+ this.pointer = pointer;
167
+ this.mouseMove();
168
+ this.click();
169
+ this.mouseEnter();
170
+ this.mouseLeave();
171
+ this.keyboard();
172
+
173
+
174
+ }
175
+
176
+ keyboard() {
177
+ this.svg.addEventListener('keydown', e => {
178
+ e.preventDefault();
179
+ console.log(e.code)
180
+ let f, vf, i, x, y, index
181
+ switch (e.code) {
182
+ case 'ArrowDown':
183
+ i = this.currentCordinate.i;
184
+ (this.currentCordinate.i != 125) && (i = this.currentCordinate.i += 5);
185
+ y = this.getY(i)
186
+ this.pointer.setAttribute('cy', y)
187
+ break;
188
+ case 'ArrowUp':
189
+ i = this.currentCordinate.i;
190
+ (this.currentCordinate.i != -15) && (i = this.currentCordinate.i -= 5);
191
+ y = this.getY(i)
192
+ this.pointer.setAttribute('cy', y)
193
+ break;
194
+ case 'ArrowRight':
195
+ f = this.currentCordinate.f;
196
+ vf = this.fToVf[f];
197
+ index = this.vfArray.indexOf(vf);
198
+ (f != 8000) && index++;
199
+ vf = this.vfArray[index]
200
+ this.currentCordinate.f = this.vfToF[vf]
201
+ x = this.getX(vf)
202
+ this.pointer.setAttribute('cx', x)
203
+ break;
204
+ case 'ArrowLeft':
205
+ f = this.currentCordinate.f;
206
+ vf = this.fToVf[f];
207
+ index = this.vfArray.indexOf(vf);
208
+ (f != 250) && index--;
209
+ vf = this.vfArray[index]
210
+ this.currentCordinate.f = this.vfToF[vf]
211
+ x = this.getX(vf)
212
+ this.pointer.setAttribute('cx', x)
213
+ break;
214
+ case 'Space':
215
+ this.updateFreqLine({ shiftKey: e.shiftKey })
216
+ break;
217
+ case 'Delete':
218
+ const container = this.svg
219
+ const dataset = { f: this.currentCordinate.f, i: this.currentCordinate.i }
220
+ this.removeSymbol({ container, dataset })
221
+ break;
222
+ default:
223
+ break;
224
+ }
225
+ })
226
+
227
+ }
228
+
229
+ drawSymbolsChart() {
230
+ const { width, height } = this.dims.symbolsChart
231
+ let style;
232
+ let x = 0
233
+ let y = 0
234
+
235
+ const symbolsChart = putSVG({ container: this.container, width, height, x, y });
236
+ symbolsChart.style.cursor = 'pointer'; // Change to pointer cursor
237
+ let container = symbolsChart
238
+ style = 'fill: none;'
239
+ putRect({ container, x, y, width, height, style });
240
+
241
+ const
242
+ dw = width / 4 - 1,
243
+ dh = height - 2,
244
+ rect = {};
245
+ x = 1; y = 1;
246
+ style = 'fill: none; stroke: brown;';
247
+
248
+ (this.side === 'R' ? ['R_AC', 'R_BC', 'R_AC_M', 'R_BC_M'] : ['L_AC', 'L_BC', 'L_AC_M', 'L_BC_M'])
249
+ .forEach(symbolName => {
250
+ const [width, height] = [dw, dh];
251
+ rect[symbolName] = putRect({ container, x, y, width, height, name: symbolName, style });
252
+ this.insertSymbol({ container, symbolName, x: x + dw / 2, y: dh / 2 })
253
+ x += dw;
254
+ });
255
+
256
+ // تعیین سمبل پیش‌فرض
257
+ this.currentSymbolName = this.side + '_AC';
258
+ this.symbol = { current: { side: this.side, type: 'AC' }, last: {} }
259
+ this.lastSymbolName = this.currentSymbolName;
260
+ rect[this.currentSymbolName].style = 'fill: yellow; stroke: brown;'
261
+
262
+ symbolsChart.onclick = (e) => {
263
+ this.currentSymbolName = e.target.dataset.name
264
+ // رنگی کردن مربع دور سمبل
265
+ rect[this.lastSymbolName].style = 'fill: none; stroke: brown;'
266
+ rect[this.currentSymbolName].style = 'fill: yellow; stroke: brown;'
267
+ this.lastSymbolName = this.currentSymbolName
268
+ }
269
+ }
270
+
271
+ mouseMove() {
272
+ // وقتی کاربر صفحه را ریسایز می‌کند مختصات آفست تغییر میکند گه با تابع زیر همیشه این مختصات چک می‌شود
273
+ const calcK = () => {
274
+ // دریافت ابعاد بر مبنای پیکسل آفست و صفحه نمایش
275
+ const clientDims = this.chartArea.getBoundingClientRect()
276
+ // ادریافت ابعاد در واحد ویوباکس
277
+ const vbDims = this.chartArea.getBBox()
278
+ const kx = vbDims.width / clientDims.width
279
+ const ky = vbDims.height / clientDims.height
280
+ return { kx, ky }
281
+ }
282
+
283
+ this.chartArea.addEventListener('mousemove', (e) => {
284
+ const { kx, ky } = calcK();
285
+ let x = e.offsetX * kx
286
+ let y = e.offsetY * ky
287
+ const f = this.currentCordinate.f = +this.getFreq(x).f;
288
+ const vf = this.getFreq(x).vf;
289
+ const i = this.currentCordinate.i = this.getIntensity(y)
290
+
291
+ if (
292
+ f >= 250 && i >= -15 && i <= 125 &&
293
+ (
294
+ this.lastCordinate.f != this.currentCordinate.f ||
295
+ this.lastCordinate.i != this.currentCordinate.i
296
+ )
297
+ ) {
298
+ x = this.getX(vf)
299
+ this.pointer.setAttribute('cx', x)
300
+ y = this.getY(i)
301
+ this.pointer.setAttribute('cy', y)
302
+ }
303
+
304
+ this.lastCordinate.f = this.currentCordinate.f
305
+ this.lastCordinate.i = this.currentCordinate.i
306
+ })
307
+ }
308
+
309
+ // تبدیل مقدار ایکس مختصات به فرکانس
310
+ getFreq(x) {
311
+ let vf = ((x - this.xArea.min) * (this.xAxisLength.hzi / this.xAxisLength.vb));
312
+ // یافتن نزدیک ترین
313
+ // const vfArray = [0, 2, 4, 5.2, 6, 7.2, 8, 9.2, 10, 11.2, 12];
314
+ let i = 0;
315
+ while (vf > this.vfArray[i]) {
316
+ i++;
317
+ }
318
+ // حالا بین دو ایندکس پیدا شده
319
+ const index = ((vf - this.vfArray[i - 1]) > (this.vfArray[i] - vf)) ? i : i - 1;
320
+ return { f: this.vfToF[this.vfArray[index]], vf: this.vfArray[index] };
321
+ }
322
+
323
+ click() {
324
+ // رویداد کلیک برای فراخوانی تابع نشاندن سمبل انتخاب شده
325
+ this.chartArea.addEventListener('click', (e) => {
326
+ const shiftKey = e.shiftKey
327
+ this.updateFreqLine({ shiftKey })
328
+ })
329
+ }
330
+
331
+ updateFreqLine({ shiftKey }) {
332
+ const nr = shiftKey;
333
+ let symbolname = this.currentSymbolName;
334
+ const f = this.currentCordinate.f
335
+ const i = this.currentCordinate.i
336
+ // console.log(f,i);
337
+
338
+ const type = symbolname.slice(2, 4)
339
+ const side = symbolname[0]
340
+ const masked = symbolname[5] === 'M' ? true : false;
341
+ nr && (symbolname += '_NR');
342
+
343
+
344
+ const x = this.getX(this.fToVf[f])
345
+ const y = this.getY(i)
346
+ let dataset = { f, type }
347
+ // اینجا رل های رسم را چک میکنیم
348
+ // اگر در این خط فرکانسی سمبل با تایپ مشابه داریم اول اون رو پاک کن
349
+ // دیتا رو چک ببین این فرکانس هست
350
+ this.removeSymbol({ container: this.svg, dataset })
351
+ dataset = { f, i, symbolname, type, side, masked, nr }
352
+ this.insertSymbol({ container: this.svg, symbolName: symbolname, x, y, dataset })
353
+ // بالا آوردن لایه آخر برای دریافت رویدادهای موس
354
+ this.svg.appendChild(this.chartArea)
355
+
356
+ if (this.data[symbolname] === undefined) this.data[symbolname] = {}
357
+ this.data[symbolname][f] = i
358
+
359
+ }
360
+
361
+ removeSymbol({ container, dataset }) {
362
+ const { side, type, f, i, masked } = dataset
363
+ // ساخت رشته کوئری با توجه به پارامترها
364
+ let query = '';
365
+ side && (query += `[data-side='${side}']`);
366
+ type && (query += `[data-type='${type}']`);
367
+ f && (query += `[data-f='${f}']`);
368
+ i && (query += `[data-i='${i}']`);
369
+ const symbol = container.querySelector(query);
370
+ if (symbol) {
371
+ const symbolname = symbol.dataset.symbolname;
372
+ delete this.data[symbolname][f]
373
+ symbol.remove();
374
+ }
375
+ }
376
+
377
+ // ناپدید شدن خطوط
378
+ mouseEnter() {
379
+ this.chartArea.addEventListener('mouseenter', () => {
380
+ this.svg.focus()
381
+ this.svg.querySelectorAll('[data-name=junction]')
382
+ .forEach(elem => elem.style.display = 'none');
383
+ })
384
+ }
385
+
386
+ // آپدیت با دیتای جدید
387
+ mouseLeave() {
388
+ this.svg.addEventListener('mouseleave', () => {
389
+ this.update({ data: this.data, side: this.side })
390
+ })
391
+ }
392
+
393
+ // تبدیل مختصات ایگرگ سیستمی به مقدار شدت
394
+ getIntensity(y) {
395
+ let i = (this.intensity.min) + (y - this.chartPadding.top) * (this.yAxisLength.db / this.yAxisLength.vb)
396
+ // رند کردن مقدار شدت با محدوده عدد پنج
397
+ const roundStep = 5
398
+ // console.log(Math.round(i / roundStep) * roundStep);
399
+
400
+ return (Math.round(i / roundStep) * roundStep)
401
+ }
402
+ // vf = f index ~ 125: 0, 250: 2, 500: 4, 750:5, ...
403
+ getX(vf) {
404
+ return ((vf - this.vf.min) * (this.xAxisLength.vb / this.xAxisLength.hzi)
405
+ )
406
+ }
407
+ // تبدیل مقدار شدت به دسی بل به مقدار مختصات ایگرگ سیستم
408
+ getY(i) {
409
+ return ((i - this.intensity.min) * (this.yAxisLength.vb / this.yAxisLength.db)
410
+ )
411
+ }
412
+
413
+ update({ data, side }) {
414
+ this.data = data
415
+ // پاک کردن نودهای سمبل دیتای قبلی در صورت وجود از نود مربوطه
416
+ this.svg.querySelectorAll('[data-name=symbol]').forEach(symbol => symbol.remove())
417
+ // پاک کردن خطوط اتصال دیتای قبلی در صورت وجود از نود مربوطه
418
+ this.svg.querySelectorAll('[data-name=junction]').forEach(symbol => symbol.remove())
419
+
420
+ const junctions = { AC: {}, BC: {}, side };
421
+ this.junctions = junctions;
422
+ for (const symbolName in data) {
423
+ for (const f in data[symbolName]) {
424
+ const i = data[symbolName][f];
425
+ const x = this.getX(this.fToVf[f]);
426
+ const y = this.getY(i);
427
+ const dataset = { f: f, i: i, symbolname: symbolName }
428
+ this.insertSymbol({ container: this.svg, symbolName, x, y, dataset });
429
+ // جمع آوری مختصات برای رسم خط بین سمبل ها اینجا انجام می‌شود
430
+ // پراپرتی تایپ فقط راهنمای دیباگ هست و کاربردی ندارد
431
+ let NR = (symbolName.at(-1) === 'R') ? true : false;
432
+ (symbolName.slice(2, 4) === 'AC') && (junctions.AC[f] = { x, y, NR, type: symbolName });
433
+ (symbolName.slice(2, 4) === 'BC') && (junctions.BC[f] = { x, y, NR, type: symbolName });
434
+ }
435
+ }
436
+ this.drawJunctions();
437
+ // بالا آوردن مستطیل احاطه کننده به بالاترین لایه برای دریافت صحیح رویدادهای موس
438
+ this.svg.appendChild(this.chartArea)
439
+ }
440
+
441
+ drawJunctions() {
442
+ // console.log(this.junctions);
443
+ // رسم خط بین نقاط
444
+ const junctions = this.junctions
445
+ let color = (junctions.side === 'R') ? 'red' : 'blue';
446
+
447
+ for (const type in junctions) {
448
+ let x1, y1, x2, y2, NR1, NR2;
449
+ for (const freq in junctions[type]) {
450
+ x1 = x2; y1 = y2; NR1 = NR2
451
+ x2 = junctions[type][freq].x
452
+ y2 = junctions[type][freq].y
453
+ NR2 = junctions[type][freq].NR
454
+ let style =
455
+ type === "BC"
456
+ ? this.styles.juncDashLine + `stroke: ${color}`
457
+ : this.styles.juncLine + `stroke: ${color}`;
458
+ x1 && !NR1 && !NR2 && putLine({ container: this.svg, x1, y1, x2, y2, style, name: 'junction' });
459
+ }
460
+ }
461
+ }
462
+
463
+ insertSymbol({ container, symbolName, x, y, dataset }) {
464
+
465
+ const width = this.symbolDims.width
466
+ const symbol = this.getSymbol(symbolName);
467
+ symbol.setAttribute('x', x - width / 2)
468
+ symbol.setAttribute('y', y - width / 2)
469
+ symbol.setAttribute('width', width)
470
+ symbol.setAttribute('height', width)
471
+ // مقادیر دیتاست را در پراپرتی های دیتا بذار
472
+ for (const key in dataset) {
473
+ symbol.setAttribute('data-' + key, dataset[key])
474
+ }
475
+
476
+ container.appendChild(symbol)
477
+ }
478
+
479
+ getSymbol(symbolName) {
480
+ const point = this.symbols[symbolName].cloneNode(true);
481
+ return point
482
+ }
483
+ }
@@ -9,7 +9,7 @@ const dims = {
9
9
  // واحد پیکسل، میلیمتر، ...
10
10
  // اگر واحد پایینی توسط بیرون تغییر کرد واحدهای بالایی باید با نسبت پایینی تغییر کنند
11
11
  width: 700,
12
- height: 700 ,
12
+ height: 700,
13
13
 
14
14
  // این فاصله خطوط محورهای بالا و چپ ادیوگرام از لبه ها هست
15
15
  chartPadding: { left: 40, top: 40, right: 30, bottom: 20 },
@@ -34,92 +34,16 @@ const dims = {
34
34
  fToVf: { 125: 0, 250: 2, 500: 4, 750: 5.2, 1000: 6, 1500: 7.2, 2000: 8, 3000: 9.2, 4000: 10, 6000: 11.2, 8000: 12, 12000: 13.2, 16000: 14 },
35
35
  intensity: { min: -20, max: 130, step: 10 },
36
36
  styles: {
37
- frequency: `text-anchor: middle; dominant-baseline: hanging;
38
- font: 1.3em Verdana, Helvetica, Arial, sans-serif; user-select: none;font-weight:bold;`,
39
- intensity: `text-anchor: end; dominant-baseline: middle;
40
- font: 1.3em Verdana, Helvetica, Arial, sans-serif; user-select: none;font-weight:bold;`,
37
+ svg: 'user-select: none; font-family: Vazir ',
38
+ frequency: `text-anchor: middle; dominant-baseline: hanging; font-size: 1.4em; font-weight:bold;`,
39
+ intensity: `text-anchor: end; dominant-baseline: middle; font-size: 1.3em; font-weight:bold;`,
41
40
  mainFreqline: `stroke: black; stroke-width: 1;`,
42
41
  semiOctavFreqline: `stroke: black; stroke-width: 1; stroke-dasharray: 4;`,
43
42
  boldLine: 'stroke: black; stroke-width: 3;',
44
-
45
43
  juncDashLine: `stroke-width: 1 ; stroke-opacity: 0.8; stroke-dasharray: 4;`,
46
44
  juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
47
45
  },
48
46
 
49
- // پس از اضافه کردن هر آیتم در زیر این تمپلت رو هم آپدیت کنید
50
- // template: {
51
- // margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
52
-
53
- // width: 700,
54
- // height: 700,
55
-
56
- // chartPadding: { left: 40, top: 50, right: 30, bottom: 10 },
57
- // symbolDims: { width: 55, height: 55 },
58
- // // virtual frequency
59
- // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
60
-
61
- // iFrequency: { min: 0, max: 14, step: 1 },
62
- // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
63
- // fToVf: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
64
- // intensity: { min: -20, max: 120, step: 10 },
65
-
66
- // styles: {
67
- // freq: ``,
68
- // line: ``,
69
- // juncDashLine: ``,
70
- // juncLine: ``,
71
- // }
72
- // },
73
-
74
- // display: {
75
- // width: 800,
76
- // height: 600,
77
-
78
-
79
- // },
80
- // rasa_audiometry: {
81
- // blank: true, // define Blank Chart for PrePrinted Chart, Lines do not draw
82
- // // width: 70.6,
83
- // // height: 70,
84
- // // margin: { left: 17, top: 18.5, },
85
- // chartPadding: { left: 0, top: 0, right: 0, bottom: 0 },
86
- // symbolDims: { width: 8, height: 8 },
87
- // // virtual frequency
88
- // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
89
-
90
- // iFrequency: { min: 0, max: 14, step: 1 },
91
- // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
92
- // fTovf: { 125: 0, 250: 2, 500: 4, 750: 5.2, 1000: 6, 1500: 7.2, 2000: 8, 3000: 9.2, 4000: 10, 6000: 11.2, 8000: 12, 12000: 13.2, 16000: 14 },
93
- // intensity: { min: -20, max: 120, step: 10 },
94
-
95
- // styles: {
96
- // freq: ``,
97
- // line: `stroke: black; stroke-width: 0.1;`,
98
- // juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
99
- // juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
100
- // }
101
- // },
102
- // combo: {
103
- // // width: 50,
104
- // // height: 40,
105
- // // margin: { left: 5, top: 5, right: 5, bottom: 5 },
106
- // chartPadding: { left: 8, top: 8, right: 5, bottom: 3 },
107
- // symbolDims: { width: 8, height: 8 },
108
- // // virtual frequency
109
- // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
110
-
111
- // iFrequency: { min: 0, max: 14, step: 1 },
112
- // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
113
- // freqToi: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
114
- // intensity: { min: -20, max: 120, step: 10 },
115
-
116
- // styles: {
117
- // freq: ``,
118
- // line: `stroke: black; stroke-width: 0.1;`,
119
- // juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
120
- // juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
121
- // }
122
- // }
123
47
  }
124
48
 
125
49
  export default dims;
@@ -0,0 +1,51 @@
1
+ const units = {
2
+ name: 'Audiogram',
3
+ margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
4
+ // این فاصله خطوط محورهای بالا و چپ ادیوگرام از لبه ها هست
5
+ chartPadding: { left: 4, top: 4, right: 3, bottom: 1 },
6
+ // واحد ویوباکس - بدون واحد
7
+ vbWidth: 70, // برای اینکه ضخامت خطوط تغییری ناهنجار نکند این ثابت میماند
8
+ vbHeight: 70, // این به نسبت تغییر می‌کند
9
+ // پایینی شکل آبجکت بالایی هست
10
+ // viewBoxObj: { 'min-x': -40, 'min-y': -40, width: 700, height: 700 },
11
+ // viewBox: '-40 -40 700 700',
12
+ // واحد پیکسل، میلیمتر، ...
13
+ // اگر واحد پایینی توسط بیرون تغییر کرد ارتفاع ویوباکس باید با نسبت پایینی تغییر کنند
14
+ width: 700,
15
+ height: 700,
16
+
17
+
18
+ symbolDims: { width: 7, height: 7 },
19
+ symbolsChart: {
20
+ width: 240, height: 60
21
+ },
22
+ // virtual frequency
23
+ mainFrequencies: [125, 250, 500, 1000, 2000, 4000, 8000],
24
+ frequencies: [
25
+ { f: 125, vf: 0, label: false }, { f: 250, vf: 2 },
26
+ { f: 500, vf: 4 }, { f: 750, vf: 5.2, semiOctav: true },
27
+ { f: 1000, vf: 6 }, { f: 1500, vf: 7.2, semiOctav: true },
28
+ { f: 2000, vf: 8 }, { f: 3000, vf: 9.2, semiOctav: true },
29
+ { f: 4000, vf: 10 }, { f: 6000, vf: 11.2, semiOctav: true },
30
+ { f: 8000, vf: 12 }, { f: 16000, vf: 14 },
31
+ ],
32
+
33
+ vf: { min: 0, max: 14, step: 1 }, // virtual frequency
34
+ vfArray: [0, 2, 4, 5.2, 6, 7.2, 8, 9.2, 10, 11.2, 12],
35
+ vfToF: { 0: 125, 2: 250, 4: 500, 5.2: 750, 6: 1000, 7.2: 1500, 8: 2000, 9.2: 3000, 10: 4000, 11.2: 6000, 12: 8000, 13: 12000, 14: 16000 },
36
+ fToVf: { 125: 0, 250: 2, 500: 4, 750: 5.2, 1000: 6, 1500: 7.2, 2000: 8, 3000: 9.2, 4000: 10, 6000: 11.2, 8000: 12, 12000: 13.2, 16000: 14 },
37
+ intensity: { min: -20, max: 130, step: 10 },
38
+ styles: {
39
+ frequency: ['text-anchor: middle', 'dominant-baseline: hanging', 'font: 2px Vazir', 'user-select: none', 'font-weight:bold'].join('; '),
40
+ intensity: ['text-anchor: end', 'dominant-baseline: middle', 'font: 2px Vazir', 'user-select: none', 'font-weight:bold'].join('; '),
41
+ mainFreqline: ['stroke: black', 'stroke-width: 0.1'].join('; '),
42
+ semiOctavFreqline: ['stroke: black', 'stroke-width: 0.1', 'stroke-dasharray: 0.5'].join('; '),
43
+ line: 'stroke: black; stroke-width: 0.1;',
44
+ boldLine: 'stroke: black; stroke-width: 0.3;',
45
+ juncDashLine: 'stroke-width: 0.1; stroke-opacity: 0.8; stroke-dasharray: 0.5;',
46
+ juncLine: 'stroke-width: 0.1; stroke-opacity: 0.8;',
47
+ },
48
+
49
+ }
50
+
51
+ export default units;