123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- import i18n from '@/i18n'
- import { sqlFunc } from './configs'
- function dataTransfer(data, schema) {
- const chartData = data.map(item => {
- const dataItem = {}
- schema.forEach(column => {
- // hasxAxis = hasxAxis || column.asxAxis
- if (column.calculFunc) {
- column.lable = `${column.Column}(${sqlFunc[column.calculFunc]})`
- } else {
- column.lable = `${column.Column}`
- }
- column.name = column.Column
- column.asxAxis = column.isDimension
- dataItem[column.Column] = item[column.Column]
- })
- return dataItem
- })
- return chartData
- }
- const chartTypeList = [
- { name: i18n.t('chartType.table'),
- icon: 'chart_table',
- type: 'table',
- matchRule: {
- desc: i18n.t('chartType.tableDesc'),
- isUsable(dimensions, calculs) {
- return true
- }
- },
- componentName: 'DataTable',
- dataTransfer(data, schema) {
- const chartData = data.map(item => {
- const dataItem = {}
- schema.forEach(column => {
- if (column.calculFunc) {
- column.name = `${column.Column}(${sqlFunc[column.calculFunc]})`
- } else {
- column.name = `${column.Column}`
- }
- dataItem[column.Column] = item[column.Column]
- })
- return dataItem
- })
- return chartData
- }
- },
- { name: i18n.t('chartType.line'),
- icon: 'chart_line',
- type: 'line',
- matchRule: {
- desc: i18n.t('chartType.lineDesc'),
- isUsable(dimensions, calculs) {
- return (dimensions.length === 1 || dimensions.length === 2) && (calculs.length >= 1)
- }
- },
- componentName: 'lineChart', dataTransfer
- },
- { name: i18n.t('chartType.bar'),
- icon: 'chart_bar',
- type: 'bar',
- matchRule: {
- desc: i18n.t('chartType.barDesc'),
- isUsable(dimensions, calculs) {
- return (dimensions.length === 1 || dimensions.length === 2) && (calculs.length >= 1)
- }
- },
- componentName: 'BarChart',
- dataTransfer
- },
- { name: i18n.t('chartType.stackBar'),
- icon: 'stack_bar',
- type: 'stackBar',
- matchRule: {
- desc: i18n.t('chartType.stackBarDesc'),
- isUsable(dimensions, calculs) {
- return (dimensions.length === 1 || dimensions.length === 2) && (calculs.length >= 2)
- }
- },
- componentName: 'StackBarChart',
- dataTransfer
- },
- { name: i18n.t('chartType.pie'),
- icon: 'chart_pie',
- type: 'pie',
- matchRule: {
- desc: i18n.t('chartType.pieDesc'),
- isUsable(dimensions, calculs) {
- return (dimensions.length === 1 && calculs.length === 1) || (dimensions.length === 0 && calculs.length >= 1)
- }
- },
- componentName: 'PieChart',
- dataTransfer
- },
- { name: i18n.t('chartType.horizontalBar'),
- icon: 'horizontal_bar',
- type: 'horizontalBar',
- matchRule: {
- desc: i18n.t('chartType.horizontalBarDesc'),
- isUsable(dimensions, calculs) {
- return (dimensions.length === 1 || dimensions.length === 2) && (calculs.length >= 1)
- }
- },
- componentName: 'HorizontalBar',
- dataTransfer
- }
- ]
- export default chartTypeList
|