| | |
| | | let vstFields = null |
| | | |
| | | if (_config.plot.datatype === 'statistics') { |
| | | _config.plot.enabled = 'false' |
| | | let _column = _config.columns.filter(col => _config.plot.InfoValue === col.field)[0] |
| | | if (_column) { |
| | | let decimal = 0 |
| | |
| | | |
| | | _config.plot.color = _config.plot.color || 'rgba(0, 0, 0, 0.65)' |
| | | |
| | | let bars = {} |
| | | if (_config.plot.enabled === 'true' && _config.plot.customs && _config.plot.customs.length > 0) { |
| | | let colors = new Map() |
| | | let Bar_axis = [] |
| | | _config.plot.customs = _config.plot.customs.map(item => { |
| | | item.name = transfield[item.type] || item.type |
| | | item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar' |
| | | item.shape = item.shape ? (item.shape[1] || '') : '' |
| | | |
| | | if (item.chartType === 'bar') { |
| | | bars[item.type] = true |
| | | Bar_axis.push(item.type) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | _config.plot.hasBar = Bar_axis.length > 0 |
| | | |
| | | if (_config.plot.mutilBar !== 'overlap') { |
| | | _config.plot.Bar_axis = Bar_axis |
| | | } |
| | | } else { |
| | | _config.plot.enabled = 'false' |
| | | } |
| | | |
| | | let colors = new Map() |
| | | |
| | | if (_config.plot.colors && _config.plot.colors.length > 0) { // 颜色设置 |
| | | if (_config.plot.datatype === 'statistics') { |
| | | if (_config.plot.ramp === 'true') { |
| | | let _s = 'l(0) ' |
| | | if (_config.plot.chartType === 'bar') { |
| | | _s = 'l(90) ' |
| | | } |
| | | _config.plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, _s + `0:${item.color} 1:${item.color1}`) |
| | | } |
| | | }) |
| | | } else { |
| | | _config.plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, item.color) |
| | | } |
| | | }) |
| | | } |
| | | } else if (_config.plot.enabled === 'true') { |
| | | if (_config.plot.ramp === 'true') { |
| | | _config.plot.colors.forEach(item => { |
| | | let _type = transfield[item.type] || item.type |
| | | if (!colors.has(_type)) { |
| | | if (bars[item.type]) { |
| | | colors.set(_type, `l(90) 0:${item.color} 1:${item.color1}` ) |
| | | } else { |
| | | colors.set(_type, `l(0) 0:${item.color} 1:${item.color1}` ) |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | _config.plot.colors.forEach(item => { |
| | | let _type = transfield[item.type] || item.type |
| | | if (!colors.has(_type)) { |
| | | colors.set(_type, item.color) |
| | | } |
| | | }) |
| | | } |
| | | } else { |
| | | if (_config.plot.ramp === 'true') { |
| | | let _s = 'l(0) ' |
| | | if (_config.plot.chartType === 'bar') { |
| | | _s = 'l(90) ' |
| | | } |
| | | _config.plot.colors.forEach(item => { |
| | | if (!transfield[item.type]) return |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], _s + `0:${item.color} 1:${item.color1}` ) |
| | | } |
| | | }) |
| | | } else { |
| | | _config.plot.colors.forEach(item => { |
| | | if (!transfield[item.type]) return |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | _config.plot.$colors = colors |
| | | } |
| | | |
| | | if (_config.plot.enabled === 'true') { |
| | | let colorIndex = 0 |
| | | let limit = chartColors.length |
| | | |
| | | if (_config.plot.colors && _config.plot.colors.length > 0) { |
| | | _config.plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let axisIndex = 0 |
| | | let hasBar = false |
| | | let Bar_axis = [] |
| | | let fields = [] |
| | | let legends = [] |
| | | |
| | | _config.plot.customs.forEach(item => { |
| | | item.name = transfield[item.type] || item.type |
| | | item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar' |
| | | item.shape = item.shape ? (item.shape[1] || '') : '' |
| | | |
| | | if (colors.has(item.type)) { |
| | | item.color = colors.get(item.type) |
| | | if (colors.has(item.name)) { |
| | | item.color = colors.get(item.name) |
| | | } else { |
| | | item.color = chartColors[colorIndex % limit] |
| | | colorIndex++ |
| | | } |
| | | |
| | | if (item.chartType === 'bar') { |
| | | hasBar = true |
| | | Bar_axis.push(item.type) |
| | | } |
| | | |
| | | if (item.axis === 'true' && axisIndex < 2) { |
| | |
| | | }) |
| | | _config.plot.customs = fields |
| | | _config.plot.legends = legends |
| | | _config.plot.hasBar = hasBar |
| | | _config.plot.axisIndex = axisIndex |
| | | |
| | | if (_config.plot.mutilBar === 'overlap') { |
| | | _config.plot.Bar_axis = [] |
| | | } else { |
| | | _config.plot.Bar_axis = Bar_axis |
| | | } |
| | | } else { |
| | | _config.plot.enabled = 'false' |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | let _data = [] |
| | | let _valfield = 'value' |
| | | let _typefield = 'key' |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.datatype === 'statistics') { |
| | | _valfield = plot.InfoValue |
| | | _typefield = plot.InfoType |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { // 颜色设置 |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | _data = this.getStaticMsg() |
| | | } else { |
| | |
| | | if (plot.enabled === 'true') { |
| | | this.customrender(data) |
| | | return |
| | | } |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { // 颜色设置 |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const ds = new DataSet() |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.$colors) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | }) |
| | | } |
| | | |
| | | if (plot.point === 'true' && plot.colors && plot.colors.length > 0) { |
| | | if (plot.point === 'true' && plot.$colors) { |
| | | let limit = chartColors.length |
| | | chart |
| | | .point() |
| | | .position(`${plot.Xaxis}*${_valfield}`) |
| | | .color(_typefield, (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | .color(_typefield) |
| | | .size(3) |
| | | .shape('circle') |
| | | } |
| | | |
| | | if (plot.interaction && plot.interaction.length) { |
| | | plot.interaction.forEach(t => { |
| | | chart.interaction(t) |
| | | }) |
| | | } |
| | | |
| | | chart.render() |
| | |
| | | |
| | | let padding = [10, 30, 30, 30] |
| | | |
| | | if (!plot.Bar_axis.length) { |
| | | if (!plot.Bar_axis) { |
| | | if (plot.axisIndex === 2) { |
| | | padding = [10, 50, 30, 50] |
| | | } else if (plot.axisIndex === 1) { |
| | |
| | | nice: true |
| | | }) |
| | | |
| | | if (plot.Bar_axis.length) { |
| | | if (plot.Bar_axis) { |
| | | const view1 = chart.createView({ |
| | | region: { |
| | | start: { x: 0, y: 0 }, |
| | |
| | | }) |
| | | |
| | | view1.data(dvt.rows) |
| | | view1.interaction('other-visible') |
| | | |
| | | view1.scale('value', { |
| | | nice: true, |
| | |
| | | |
| | | view1.legend(false) |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (plot.adjust !== 'stack') { |
| | | let _chart = view1 |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.$colors) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.$colors) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | }) |
| | | |
| | | view2.data(dv.rows) |
| | | view2.interaction('other-visible') |
| | | |
| | | view2.legend(false) |
| | | |
| | | plot.customs.forEach((item, i) => { |
| | | if (item.chartType === 'bar' && !plot.Bar_axis.length) { |
| | | if (item.chartType === 'bar' && !plot.Bar_axis) { |
| | | view2.axis(item.name, item.axis) |
| | | |
| | | view2.scale(item.name, { |
| | |
| | | _chart.style({ radius: [plot.barRadius, plot.barRadius, 0, 0] }) |
| | | } |
| | | } else if (item.chartType === 'line') { |
| | | if (!plot.Bar_axis.length) { |
| | | if (!plot.Bar_axis) { |
| | | view2.axis(item.name, item.axis) |
| | | } else { |
| | | view2.axis(item.name, { grid: null, title: null, label: null }) |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.interaction && plot.interaction.length) { |
| | | plot.interaction.forEach(t => { |
| | | if (t === 'element-active' || t === 'element-highlight') { |
| | | chart.interaction(t) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | chart.render() |
| | | } |
| | | |
| | |
| | | let _valfield = 'value' |
| | | let _typefield = 'key' |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.datatype === 'statistics') { |
| | | _valfield = plot.InfoValue |
| | | _typefield = plot.InfoType |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { // 颜色设置 |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | _data = this.getStaticMsg() |
| | | } else { |
| | |
| | | if (plot.enabled === 'true') { |
| | | this.customrender(data) |
| | | return |
| | | } |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { // 颜色设置 |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const ds = new DataSet() |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.$colors) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.$colors) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | if (plot.$colors.has(key)) { |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | |
| | | }) |
| | | } |
| | | |
| | | if (plot.interaction && plot.interaction.length) { |
| | | plot.interaction.forEach(t => { |
| | | chart.interaction(t) |
| | | }) |
| | | } |
| | | |
| | | chart.render() |
| | | } |
| | | |