(baseOptions, axis, data)
| 1 | const { checkIsPercent, formatNumber, getAxesWithFilter, processMultiQuotaData } = require('./utils') |
| 2 | |
| 3 | function getLineOptions(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: 'view', |
| 35 | data: _data.data, |
| 36 | encode: { |
| 37 | x: x[0].value, |
| 38 | y: y[0].value, |
| 39 | color: series.length > 0 ? series[0].value : undefined, |
| 40 | }, |
| 41 | axis: { |
| 42 | x: { |
| 43 | title: x[0].name, |
| 44 | labelFontSize: 12, |
| 45 | labelAutoHide: { |
| 46 | type: 'hide', |
| 47 | keepHeader: true, |
| 48 | keepTail: true, |
| 49 | }, |
| 50 | labelAutoRotate: false, |
| 51 | labelAutoWrap: true, |
| 52 | labelAutoEllipsis: true, |
| 53 | }, |
| 54 | y: { |
| 55 | title: y[0].name, |
| 56 | labelFormatter: (value) => { |
| 57 | return String(formatNumber(value)) |
| 58 | }, |
| 59 | }, |
| 60 | }, |
no test coverage detected