MCPcopy Create free account
hub / github.com/dataease/SQLBot / init

Method init

frontend/src/views/chat/component/charts/Bar.ts:16–170  ·  view source on GitHub ↗
(axis: Array<ChartAxis>, data: Array<ChartData>)

Source from the content-addressed store, hash-verified

14 }
15
16 init(axis: Array<ChartAxis>, data: Array<ChartData>) {
17 super.init(axis, data)
18
19 const axes = getAxesWithFilter(this.axis)
20
21 if (axes.x.length == 0 || axes.y.length == 0) {
22 console.debug({ instance: this })
23 return
24 }
25
26 let config = {
27 data: data,
28 y: axes.y,
29 series: axes.series,
30 }
31 if (axes.multiQuota.length > 0) {
32 config = processMultiQuotaData(
33 axes.x,
34 config.y,
35 axes.multiQuota,
36 axes.multiQuotaName,
37 config.data
38 )
39 }
40
41 const x = axes.x
42 const y = config.y
43 const series = config.series
44
45 const _data = checkIsPercent(y, config.data)
46
47 console.debug({ 'render-info': { x: x, y: y, series: series, data: _data }, instance: this })
48
49 const options: G2Spec = {
50 ...this.chart.options(),
51 type: 'interval',
52 data: _data.data,
53 coordinate: { transform: [{ type: 'transpose' }] },
54 encode: {
55 x: x[0].value,
56 y: y[0].value,
57 color: series.length > 0 ? series[0].value : undefined,
58 },
59 style: {
60 radiusTopLeft: (d: ChartData) => {
61 if (d[y[0].value] && d[y[0].value] > 0) {
62 return 4
63 }
64 return 0
65 },
66 radiusTopRight: (d: ChartData) => {
67 if (d[y[0].value] && d[y[0].value] > 0) {
68 return 4
69 }
70 return 0
71 },
72 radiusBottomLeft: (d: ChartData) => {
73 if (d[y[0].value] && d[y[0].value] < 0) {

Callers

nothing calls this directly

Calls 6

getAxesWithFilterFunction · 0.90
processMultiQuotaDataFunction · 0.90
checkIsPercentFunction · 0.90
formatNumberFunction · 0.90
initMethod · 0.65
debugMethod · 0.45

Tested by

no test coverage detected