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

Function getBarOptions

g2-ssr/charts/bar.js:3–139  ·  view source on GitHub ↗
(baseOptions, axis, data)

Source from the content-addressed store, hash-verified

1const { checkIsPercent, formatNumber, getAxesWithFilter, processMultiQuotaData } = require('./utils')
2
3function getBarOptions(baseOptions, axis, data) {
4
5 const axes = getAxesWithFilter(axis)
6
7 if (axes.x.length === 0 || axes?.y?.length === 0) {
8 return
9 }
10
11 let config = {
12 data: data,
13 y: axes.y,
14 series: axes.series,
15 }
16 if (axes.multiQuota.length > 0) {
17 config = processMultiQuotaData(
18 axes.x,
19 config.y,
20 axes.multiQuota,
21 axes.multiQuotaName,
22 config.data,
23 )
24 }
25
26 const x = axes.x
27 const y = config.y
28 const series = config.series
29
30 const _data = checkIsPercent(y, config.data)
31
32 const options = {
33 ...baseOptions,
34 type: 'interval',
35 data: _data.data,
36 coordinate: { transform: [{ type: 'transpose' }] },
37 encode: {
38 x: x[0].value,
39 y: y[0].value,
40 color: series.length > 0 ? series[0].value : undefined,
41 },
42 style: {
43 radiusTopLeft: (d) => {
44 if (d[y[0].value] && d[y[0].value] > 0) {
45 return 4
46 }
47 return 0
48 },
49 radiusTopRight: (d) => {
50 if (d[y[0].value] && d[y[0].value] > 0) {
51 return 4
52 }
53 return 0
54 },
55 radiusBottomLeft: (d) => {
56 if (d[y[0].value] && d[y[0].value] < 0) {
57 return 4
58 }
59 return 0
60 },

Callers 1

getOptionsFunction · 0.85

Calls 4

getAxesWithFilterFunction · 0.70
processMultiQuotaDataFunction · 0.70
checkIsPercentFunction · 0.70
formatNumberFunction · 0.70

Tested by

no test coverage detected