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