/* * @description: 配置,参考https://g2plot.antv.antgroup.com/examples * @Date: 2023-03-27 14:38:23 * @Author: xing.heng */ // 分类 const category = 'Area' // 标题 const title = '堆叠面积图' // 类别, new Line() const chartType = 'Area' // 用于标识,唯一,和文件夹名称一致 const name = 'DuiChengMianJiTu' // 右侧配置项 const setting = [ { label: '维度', // 设置组件类型, select / input / colorPicker type: 'select', // 字段 field: 'xField', optionField: 'xField', // 对应options中的字段 // 是否多选 multiple: false, // 绑定的值 value: '', // tab页。 data: 数据, custom: 自定义 tabName: 'data' }, { label: '指标', // 设置组件类型 type: 'select', // 字段 field: 'yField', // 对应options中的字段 optionField: 'yField', // 是否多选 multiple: false, value: '', tabName: 'data' }, { label: '分组', // 设置组件类型 type: 'select', // 字段 field: 'seriesField', // 对应options中的字段 optionField: 'seriesField', // 是否多选 multiple: false, value: '', tabName: 'data' }, /** 样式配置 **/ // 图表 graph { label: '曲线平滑', type: 'switch', // 设置组件类型 field: 'smooth', // 字段 optionField: 'smooth', // 对应options中的字段 value: false, tabName: 'custom', groupName: 'graph' }, { label: '从0基准线填充', type: 'switch', // 设置组件类型 field: 'startOnZero', // 字段 optionField: 'startOnZero', // 对应options中的字段 value: true, tabName: 'custom', groupName: 'graph' }, { label: '颜色配置', // 设置组件类型 type: 'colorSelect', // 字段 field: 'color', // 对应options中的字段 optionField: 'color', value: ['#5B8FF9', '#61DDAA', '#5D7092', '#F6BD16', '#6F5EF9', '#6DC8EC', '#945FB9', '#FF9845', '#1E9493', '#FF99C3'], tabName: 'custom' }, // 网格线 grid { label: '宽度', type: 'inputNumber', field: 'yAxis_grid_line_style_lineWidth', optionField: 'yAxis.grid.line.style.lineWidth', value: 1, tabName: 'custom', groupName: 'grid' }, { label: '颜色', type: 'colorPicker', field: 'yAxis_grid_line_style_stroke', optionField: 'yAxis.grid.line.style.stroke', value: '#d0d0d0', tabName: 'custom', groupName: 'grid' }, // 图例 legend { label: '显示', type: 'switch', // 设置组件类型 field: 'legendEnable', // 字段 optionField: 'legendEnable', // 对应options中的字段 value: false, tabName: 'custom', groupName: 'legend' }, { label: '位置', type: 'select', // 设置组件类型 field: 'legendPosition', // 字段 optionField: 'legendPosition', // 对应options中的字段 // 是否多选 multiple: false, value: 'top', tabName: 'custom', options: [ { label: '顶部', value: 'top' }, { label: '左上角', value: 'top-left' }, { label: '右上角', value: 'top-right' }, { label: '左侧', value: 'left' }, // { label: '左上方', value: 'left-top' }, // { label: '左下方', value: 'left-bottom' }, { label: '右侧', value: 'right' }, // { label: '右上方', value: 'right-top' }, // { label: '右下方', value: 'right-bottom' }, { label: '底部', value: 'bottom' }, { label: '左下角', value: 'bottom-left' }, { label: '右下角', value: 'bottom-right' } ], groupName: 'legend' }, // X轴 xAxis { label: '标题', type: 'input', field: 'xAxis_title_text', optionField: 'xAxis.title.text', value: '', tabName: 'custom', groupName: 'xAxis' }, { label: '标题位置', type: 'select', field: 'xAxis_title_position', optionField: 'xAxis.title.position', value: 'end', tabName: 'custom', options: [ { label: '左', value: 'start' }, { label: '中', value: 'center' }, { label: '右', value: 'end' }], groupName: 'xAxis' }, { label: '标题字体大小', type: 'inputNumber', field: 'xAxis_title_style_fontSize', optionField: 'xAxis.title.style.fontSize', value: 12, tabName: 'custom', groupName: 'xAxis' }, { label: '标题颜色', type: 'colorPicker', field: 'xAxis_title_style_fill', optionField: 'xAxis.title.style.fill', // 是否多选 multiple: false, value: '#8C8C8C', tabName: 'custom', groupName: 'xAxis' }, { label: '标签大小', type: 'inputNumber', field: 'xAxis_label_style_fontSize', optionField: 'xAxis.label.style.fontSize', value: 12, tabName: 'custom', groupName: 'xAxis' }, { label: '标签颜色', type: 'colorPicker', field: 'xAxis_label_style_fill', optionField: 'xAxis.label.style.fill', // 是否多选 multiple: false, value: '#8C8C8C', tabName: 'custom', groupName: 'xAxis' }, { label: '轴线宽度', type: 'inputNumber', field: 'xAxis_line_style_lineWidth', optionField: 'xAxis.line.style.lineWidth', value: 1, tabName: 'custom', groupName: 'xAxis' }, { label: '轴线颜色', type: 'colorPicker', field: 'xAxis_line_style_stroke', optionField: 'xAxis.line.style.stroke', // 是否多选 multiple: false, value: '#d0d0d0', tabName: 'custom', groupName: 'xAxis' }, { label: '刻度线宽度', type: 'inputNumber', field: 'xAxis_tickLine_style_lineWidth', optionField: 'xAxis.tickLine.style.lineWidth', value: 1, tabName: 'custom', groupName: 'xAxis' }, { label: '刻度线颜色', type: 'colorPicker', field: 'xAxis_tickLine_style_stroke', optionField: 'xAxis.tickLine.style.stroke', // 是否多选 multiple: false, value: '#d0d0d0', tabName: 'custom', groupName: 'xAxis' }, { label: '标签过多时旋转', type: 'switch', field: 'xAxis_label_autoRotate', optionField: 'xAxis.label.autoRotate', value: false, tabName: 'custom', groupName: 'xAxis' }, { label: '标签过多时隐藏', type: 'switch', field: 'xAxis_label_autoHide', optionField: 'xAxis.label.autoHide', value: true, tabName: 'custom', groupName: 'xAxis' }, { label: '标签过长时省略', type: 'switch', field: 'xAxis_label_autoEllipsis', optionField: 'xAxis.label.autoEllipsis', value: true, tabName: 'custom', groupName: 'xAxis' }, // Y轴 yAxis { label: '标题', type: 'input', field: 'yAxis_title_text', optionField: 'yAxis.title.text', value: '', tabName: 'custom', groupName: 'yAxis' }, { label: '标题位置', type: 'select', field: 'yAxis_title_position', optionField: 'yAxis.title.position', value: 'end', tabName: 'custom', options: [ { label: '下', value: 'start' }, { label: '中', value: 'center' }, { label: '上', value: 'end' }], groupName: 'yAxis' }, { label: '标题字体大小', type: 'inputNumber', field: 'yAxis_title_style_fontSize', optionField: 'yAxis.title.style.fontSize', value: 12, tabName: 'custom', groupName: 'yAxis' }, { label: '标题颜色', type: 'colorPicker', field: 'yAxis_title_style_fill', optionField: 'yAxis.title.style.fill', // 是否多选 multiple: false, value: '#8C8C8C', tabName: 'custom', groupName: 'yAxis' }, { label: '显示标签', type: 'switchNumber', field: 'yAxis_label_style_opacity', optionField: 'yAxis.label.style.opacity', value: 1, tabName: 'custom', groupName: 'yAxis' }, { label: '标签字体大小', type: 'inputNumber', field: 'yAxis_label_style_fontSize', optionField: 'yAxis.label.style.fontSize', value: 12, tabName: 'custom', groupName: 'yAxis' }, { label: '标签字体颜色', type: 'colorPicker', field: 'yAxis_label_style_fill', optionField: 'yAxis.label.style.fill', // 是否多选 multiple: false, value: '#8C8C8C', tabName: 'custom', groupName: 'yAxis' }, { label: '轴线宽度', type: 'inputNumber', field: 'yAxis_line_lineWidth', optionField: 'yAxis.line.style.lineWidth', value: 1, tabName: 'custom', groupName: 'yAxis' }, { label: '轴线颜色', type: 'colorPicker', field: 'yAxis_line_stroke', optionField: 'yAxis.line.style.stroke', // 是否多选 multiple: false, value: 'rgba(255,255,255,0)', tabName: 'custom', groupName: 'yAxis' }, // 边距 padding { label: '图表边距', type: 'padding', field: 'appendPadding', optionField: 'appendPadding', value: [20, 20, 20, 20], tabName: 'custom', groupName: 'padding' } ] // 模拟数据 const data = [ { country: '北美', date: 1965, value: 1390.5 }, { country: '北美', date: 1966, value: 1469.5 }, { country: '北美', date: 1967, value: 1521.7 }, { country: '北美', date: 1968, value: 1615.9 }, { country: '北美', date: 1969, value: 1703.7 }, { country: '中南美', date: 1965, value: 109.2 }, { country: '中南美', date: 1966, value: 115.7 }, { country: '中南美', date: 1967, value: 120.5 }, { country: '中南美', date: 1968, value: 128 }, { country: '中南美', date: 1969, value: 134.4 }, { country: '欧洲', date: 1965, value: 1058.1 }, { country: '欧洲', date: 1966, value: 1089.7 }, { country: '欧洲', date: 1967, value: 1121.7 }, { country: '欧洲', date: 1968, value: 1196.6 }, { country: '欧洲', date: 1969, value: 1285.5 }, { country: 'CIS 地区', date: 1965, value: 593.3 }, { country: 'CIS 地区', date: 1966, value: 630.9 }, { country: 'CIS 地区', date: 1967, value: 663.2 }, { country: 'CIS 地区', date: 1968, value: 687.8 }, { country: 'CIS 地区', date: 1969, value: 719 }, { country: '中东', date: 1965, value: 48.3 }, { country: '中东', date: 1966, value: 50.4 }, { country: '中东', date: 1967, value: 52.7 }, { country: '中东', date: 1968, value: 55.6 }, { country: '中东', date: 1969, value: 58.5 }, { country: '非洲', date: 1965, value: 60.6 }, { country: '非洲', date: 1966, value: 63.3 }, { country: '非洲', date: 1967, value: 64 }, { country: '非洲', date: 1968, value: 67.4 }, { country: '非洲', date: 1969, value: 68.9 } ] // 配置处理脚本 const optionHandler = 'option.legend = option.legendEnable ? {position: setting.find(settingItem=>settingItem.field === \'legendPosition\').value} : false;' // 数据处理脚本 const dataHandler = '' // 图表配置 new Line('domName', option) const option = { // 数据将要放入到哪个字段中 dataKey: 'data', data, appendPadding: [20, 20, 20, 20], // 设置图标的边距 xField: 'date', yField: 'value', color: ['#5B8FF9', '#61DDAA', '#5D7092', '#F6BD16', '#6F5EF9', '#6DC8EC', '#945FB9', '#FF9845', '#1E9493', '#FF99C3'], seriesField: 'country', smooth: false, legendEnable: false, legendLayout: 'vertical', legendPosition: 'top', legend: false, startOnZero: true, xAxis: { title: { text: '', position: 'end', style: { fill: '#8C8C8C', fontSize: 12 } }, label: { autoRotate: false, autoHide: true, autoEllipsis: true, style: { fill: '#8C8C8C', fontSize: 12 } }, line: { style: { stroke: '#d0d0d0', lineWidth: 1 } }, tickLine: { style: { stroke: '#d0d0d0', lineWidth: 1 } } }, yAxis: { title: { text: '', position: 'end', autoRotate: false, // rotation: Math.PI / 2, style: { fill: '#8C8C8C', fontSize: 12 } }, grid: { line: { style: { stroke: '#d0d0d0', lineWidth: 1, strokeOpacity: 0.7 } } }, label: { style: { fill: '#8C8C8C', fontSize: 12, opacity: 1 } }, line: { style: { stroke: 'rgba(255,255,255,0)', lineWidth: 1 }, stroke: 'rgba(255,255,255,0)', lineWidth: 1 } } // areaStyle: { // fill: "#94c6ff" // }, // line: { // color: '' // }, } export default { category, title, chartType, name, option, setting, optionHandler, dataHandler }