| | |
| | | let type = plot.type |
| | | let color = plot.color |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(item.label)) { |
| | | colors.set(item.label, item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let _data = this.getnestdata() |
| | | |
| | | const dvx = new DataView().source(_data) |
| | |
| | | .interval() |
| | | .adjust('stack') |
| | | .position(Y_axis) |
| | | .color(type) |
| | | .tooltip(`${type}*${Y_axis}`, (type, percent) => { |
| | | if (plot.show !== 'value') { |
| | | percent = (percent * 100).toFixed(2) + '%' |
| | |
| | | lineWidth: 1, |
| | | stroke: '#fff', |
| | | }) |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | chart1.color(type, (_type) => { |
| | | if (colors.has(_type)) { |
| | | return colors.get(_type) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | | chart1.color(type) |
| | | } |
| | | |
| | | if (plot.label !== 'false') { |
| | | chart1.label(type, { |
| | |
| | | .interval() |
| | | .adjust('stack') |
| | | .position(Y_axis) |
| | | .color(X_axis) |
| | | .tooltip(`${X_axis}*${Y_axis}`, (name, value) => { |
| | | if (plot.show !== 'value') { |
| | | value = (value * 100).toFixed(2) + '%' |
| | |
| | | lineWidth: 1, |
| | | stroke: '#fff', |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | chart2.color(X_axis, (type) => { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | | chart2.color(X_axis) |
| | | } |
| | | |
| | | if (plot.label !== 'false') { |
| | | if (plot.label === 'inner') { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(X_axis, (type) => { |
| | | if (colors.get(type)) { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colors.set(type, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(X_axis, (type) => { |
| | | if (colors.get(type)) { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colors.set(type, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |