hayun-vite 0.4.0 → 0.4.1

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