| | |
| | | |
| | | /** |
| | | * @description 获取图表视图配置表单 |
| | | * @param {object} card // 搜索条件对象 |
| | | * @param {object} card // 图表对象 |
| | | * @param {Array} columns // 显示列 |
| | | * @param {String} type // 图表类型 |
| | | * @param {String} setting // 页面设置 |
| | | */ |
| | | export function getChartOptionForm (card, columns, type) { |
| | | export function getChartOptionForm (card, columns, setting) { |
| | | let shapes = [] |
| | | |
| | | if (type === 'line') { |
| | | if (card.chartType === 'line') { |
| | | shapes = [ |
| | | { field: 'smooth', label: 'smooth' }, |
| | | { field: 'line', label: 'line' }, |
| | |
| | | { field: 'hvh', label: 'hvh' }, |
| | | { field: 'vhv', label: 'vhv' } |
| | | ] |
| | | } else if (type === 'bar') { |
| | | } else if (card.chartType === 'bar') { |
| | | shapes = [ |
| | | { field: 'rect', label: 'rect' }, |
| | | { field: 'hollow-rect', label: 'hollow-rect' }, |
| | |
| | | { field: 'funnel', label: 'funnel' }, |
| | | { field: 'pyramid', label: 'pyramid' } |
| | | ] |
| | | } else if (type === 'pie') { |
| | | } else if (card.chartType === 'pie') { |
| | | shapes = [ |
| | | { field: 'pie', label: '饼图' }, |
| | | { field: 'ring', label: '环图' } |
| | |
| | | |
| | | return [ |
| | | { |
| | | type: 'radio', |
| | | key: 'datatype', |
| | | label: '数据类型', |
| | | initVal: card.datatype || 'query', |
| | | tooltip: '统计图表适用于表格不分页,且数据需要转换', |
| | | required: false, |
| | | readonly: !(setting.laypage === 'false'), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [ |
| | | { value: 'query', text: Formdict['header.form.query'] }, |
| | | { value: 'statistics', text: Formdict['header.form.statistics'] } |
| | | ] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'Xaxis', |
| | | label: type === 'pie' ? 'Text' : 'X-轴', |
| | | label: card.chartType === 'pie' ? 'Text' : 'X-轴', |
| | | initVal: card.Xaxis || '', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'text') |
| | |
| | | { |
| | | type: 'select', |
| | | key: 'Yaxis', |
| | | label: type === 'pie' ? 'Value' : 'Y-轴', |
| | | initVal: type === 'pie' ? card.Yaxis || '' : card.Yaxis || [], |
| | | multi: type !== 'pie', |
| | | label: card.chartType === 'pie' ? 'Value' : 'Y-轴', |
| | | initVal: card.chartType === 'pie' ? card.Yaxis || '' : card.Yaxis || [], |
| | | multi: card.chartType !== 'pie', |
| | | hidden: card.datatype === 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'number') |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'InfoType', |
| | | label: '类型', |
| | | initVal: card.InfoType || '', |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'text') |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'InfoValue', |
| | | label: '值', |
| | | initVal: card.InfoValue || '', |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true, |
| | | options: columns.filter(col => col.type === 'number') |
| | | }, |
| | |
| | | label: '形状', |
| | | initVal: card.shape || (shapes[0] && shapes[0].field), |
| | | required: false, |
| | | hidden: !['line', 'bar', 'pie'].includes(type), |
| | | forbid: !['line', 'bar', 'pie'].includes(card.chartType), |
| | | options: shapes |
| | | }, |
| | | { |
| | |
| | | label: '坐标', |
| | | initVal: card.coordinate || 'angle', |
| | | required: false, |
| | | hidden: !['line', 'bar'].includes(type), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'angle', |
| | | text: '二维坐标' |
| | |
| | | label: '点图', |
| | | initVal: card.point || 'false', |
| | | required: false, |
| | | hidden: !['line'].includes(type), |
| | | forbid: !['line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | |
| | | label: '变换', |
| | | initVal: card.transpose || 'false', |
| | | required: false, |
| | | hidden: !['line', 'bar'].includes(type), |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: Formdict['header.form.true'] |
| | |
| | | label: '显示值', |
| | | initVal: card.pieshow || 'percent', |
| | | required: false, |
| | | hidden: !['pie'].includes(type), |
| | | forbid: !['pie'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'percent', |
| | | text: '百分比' |
| | |
| | | type: 'radio', |
| | | key: 'label', |
| | | label: '文本标签', |
| | | initVal: card.label || (type === 'pie' ? 'true' : 'false'), |
| | | initVal: card.label || (card.chartType === 'pie' ? 'true' : 'false'), |
| | | required: false, |
| | | hidden: !['pie', 'line'].includes(type), |
| | | forbid: !['pie', 'line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | |
| | | label: '标签布局', |
| | | initVal: card.labelLayout || 'normal', |
| | | required: false, |
| | | hidden: !['pie'].includes(type), |
| | | forbid: !['pie'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'normal', |
| | | text: '常规' |
| | |
| | | label: '多柱排列', |
| | | initVal: card.adjust || 'dodge', |
| | | required: false, |
| | | hidden: !['bar'].includes(type), |
| | | forbid: !['bar'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'dodge', |
| | | text: '分组' |
| | |
| | | value: 'stack', |
| | | text: '堆叠' |
| | | }] |
| | | } |
| | | }, { |
| | | type: 'radio', |
| | | key: 'repeat', |
| | | label: '重复数据', |
| | | initVal: card.repeat || 'unrepeat', |
| | | required: false, |
| | | // forbid: !['bar', 'pie', 'line'].includes(card.chartType), |
| | | options: [{ |
| | | value: 'unrepeat', |
| | | text: '去重' |
| | | }, { |
| | | value: 'average', |
| | | text: '平均' |
| | | }, { |
| | | value: 'cumsum', |
| | | text: '累加' |
| | | }] |
| | | }, { |
| | | type: 'number', |
| | | key: 'InfoDefNumber', |
| | | label: '展示数', |
| | | tooltip: '默认显示类型数量', |
| | | min: 1, |
| | | max: 50, |
| | | decimal: 0, |
| | | initVal: card.InfoDefNumber || 5, |
| | | forbid: !['line', 'bar'].includes(card.chartType), |
| | | hidden: card.datatype !== 'statistics', |
| | | required: true |
| | | }, |
| | | ] |
| | | } |
| | | |