feat: antv组合图插件 颜色设置增加渐变与透明度
This commit is contained in:
parent
c110087e72
commit
ddf7207fc4
@ -120,7 +120,6 @@
|
|||||||
v-show="showProperty('customColor')"
|
v-show="showProperty('customColor')"
|
||||||
class="custom-color-style"
|
class="custom-color-style"
|
||||||
>
|
>
|
||||||
aaa
|
|
||||||
<div
|
<div
|
||||||
v-for="(item,index) in colorForm.seriesColors"
|
v-for="(item,index) in colorForm.seriesColors"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|||||||
@ -53,18 +53,27 @@
|
|||||||
</el-popover>
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item
|
||||||
|
:label="$t('chart.gradient')"
|
||||||
|
class="form-item"
|
||||||
|
>
|
||||||
|
<el-checkbox
|
||||||
|
v-model="colorForm.gradient"
|
||||||
|
@change="changeColorCase"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<!-- <el-form-item :label="$t('chart.not_alpha')" class="form-item form-item-slider">
|
<el-form-item :label="$t('chart.not_alpha')" class="form-item form-item-slider">
|
||||||
<el-slider v-model="colorForm.alpha" show-input :show-input-controls="false" input-size="mini"
|
<el-slider v-model="colorForm.alpha" show-input :show-input-controls="false" input-size="mini"
|
||||||
@change="changeColorCase"/>
|
@change="changeColorCase"/>
|
||||||
</el-form-item>-->
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-col>
|
</el-col>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {COLOR_PANEL, DEFAULT_COLOR_CASE} from '@/utils/map'
|
import {COLOR_PANEL, DEFAULT_COLOR_CASE} from '../../utils/map'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ColorSelector',
|
name: 'ColorSelector',
|
||||||
|
|||||||
@ -63,6 +63,12 @@ export function hexColorToRGBA(hex, alpha) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setGradientColor(rawColor, show = false, angle = 0) {
|
||||||
|
const item = rawColor.split(',')
|
||||||
|
item.splice(3, 1, '0.3)')
|
||||||
|
return show ? `l(${angle}) 0:${item.join(',')} 1:${rawColor}` : rawColor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {Mix} from '@antv/g2plot'
|
import {Mix} from '@antv/g2plot'
|
||||||
import {uuid, hexColorToRGBA} from '../../../utils/chartmix'
|
import {uuid, hexColorToRGBA, setGradientColor} from '../../../utils/chartmix'
|
||||||
import ViewTrackBar from '../../../components/views/ViewTrackBar'
|
import ViewTrackBar from '../../../components/views/ViewTrackBar'
|
||||||
import {getRemark} from "../../../components/views/utils";
|
import {getRemark} from "../../../components/views/utils";
|
||||||
import {
|
import {
|
||||||
@ -41,12 +41,13 @@ import {
|
|||||||
DEFAULT_XAXIS_STYLE,
|
DEFAULT_XAXIS_STYLE,
|
||||||
DEFAULT_YAXIS_STYLE,
|
DEFAULT_YAXIS_STYLE,
|
||||||
transAxisPosition,
|
transAxisPosition,
|
||||||
getLineDash
|
getLineDash, DEFAULT_COLOR_CASE
|
||||||
} from '../../../utils/map';
|
} from '../../../utils/map';
|
||||||
import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate';
|
import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import {clear} from 'size-sensor'
|
import {clear} from 'size-sensor'
|
||||||
import {valueFormatter} from '../../../utils/formatter'
|
import {valueFormatter} from '../../../utils/formatter'
|
||||||
|
import fa from "element-ui/src/locale/lang/fa";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ChartComponent',
|
name: 'ChartComponent',
|
||||||
@ -276,7 +277,9 @@ export default {
|
|||||||
let yaxisCount = yaxisList.length;
|
let yaxisCount = yaxisList.length;
|
||||||
|
|
||||||
let customAttr = undefined;
|
let customAttr = undefined;
|
||||||
|
let gradient = false;
|
||||||
let colors = undefined;
|
let colors = undefined;
|
||||||
|
let alpha = DEFAULT_COLOR_CASE.alpha;
|
||||||
let labelSetting = undefined;
|
let labelSetting = undefined;
|
||||||
let labelPosition = 'middle';
|
let labelPosition = 'middle';
|
||||||
if (this.chart.customAttr) {
|
if (this.chart.customAttr) {
|
||||||
@ -284,6 +287,8 @@ export default {
|
|||||||
if (customAttr) {
|
if (customAttr) {
|
||||||
if (customAttr.color) {
|
if (customAttr.color) {
|
||||||
colors = customAttr.color.colors;
|
colors = customAttr.color.colors;
|
||||||
|
alpha = customAttr.color.alpha;
|
||||||
|
gradient = customAttr.color.gradient;
|
||||||
}
|
}
|
||||||
if (customAttr.label) {
|
if (customAttr.label) {
|
||||||
labelSetting = customAttr.label.show ? {
|
labelSetting = customAttr.label.show ? {
|
||||||
@ -322,6 +327,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let color = colors && _index < colors.length ? hexColorToRGBA(colors[_index], alpha) : undefined;
|
||||||
|
if (color && gradient) {
|
||||||
|
color = setGradientColor(color, true, 270)
|
||||||
|
console.log(color)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: _chartType,
|
type: _chartType,
|
||||||
name: t.name,
|
name: t.name,
|
||||||
@ -347,7 +358,7 @@ export default {
|
|||||||
yAxis: {
|
yAxis: {
|
||||||
position: 'left',
|
position: 'left',
|
||||||
},
|
},
|
||||||
color: colors && _index < colors.length ? colors[_index] : undefined,
|
color: color,
|
||||||
label: _labelSetting,
|
label: _labelSetting,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +377,6 @@ export default {
|
|||||||
|
|
||||||
names.push(t.name);
|
names.push(t.name);
|
||||||
|
|
||||||
|
|
||||||
const _chartType = this.getChartType(yaxisExtList[_index].chartType);
|
const _chartType = this.getChartType(yaxisExtList[_index].chartType);
|
||||||
|
|
||||||
if (_labelSetting) {
|
if (_labelSetting) {
|
||||||
@ -377,6 +387,12 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let color = colors && (yaxisCount + _index) < colors.length ? hexColorToRGBA(colors[yaxisCount + _index], alpha) : undefined;
|
||||||
|
if (color && gradient) {
|
||||||
|
color = setGradientColor(color, true, 270)
|
||||||
|
console.log(color)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: _chartType,
|
type: _chartType,
|
||||||
name: t.name,
|
name: t.name,
|
||||||
@ -402,7 +418,7 @@ export default {
|
|||||||
yAxis: {
|
yAxis: {
|
||||||
position: 'right',
|
position: 'right',
|
||||||
},
|
},
|
||||||
color: colors && (yaxisCount + _index) < colors.length ? colors[yaxisCount + _index] : undefined,
|
color: color,
|
||||||
label: _labelSetting,
|
label: _labelSetting,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user