feat(图表-对称柱状图): 支持设置显示方向

This commit is contained in:
jianneng-fit2cloud 2024-05-11 16:59:24 +08:00
parent 035462e015
commit ccb61c186f
3 changed files with 38 additions and 3 deletions

View File

@ -229,6 +229,10 @@ declare interface ChartBasicStyle {
* 其他项的标签
*/
topNLabel: string
/**
* 对称柱状图方向
*/
layout: 'horizontal' | 'vertical'
}
/**
* 表头属性

View File

@ -202,6 +202,23 @@ onMounted(() => {
</el-checkbox>
</el-form-item>
<el-form-item
:label="t('chart.orient')"
class="form-item"
:class="'form-item-' + themes"
v-if="showProperty('layout')"
>
<el-radio-group
size="small"
:effect="themes"
v-model="state.basicStyleForm.layout"
@change="changeBasicStyle('layout')"
>
<el-radio :effect="themes" label="horizontal">{{ t('chart.horizontal') }}</el-radio>
<el-radio :effect="themes" label="vertical">{{ t('chart.vertical') }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
class="form-item"
v-if="showProperty('tableLayoutMode')"

View File

@ -58,7 +58,7 @@ export class BidirectionalHorizontalBar extends G2PlotChartView<
]
propertyInner = {
'background-overall-component': ['all'],
'basic-style-selector': ['colors', 'alpha', 'gradient'],
'basic-style-selector': ['colors', 'alpha', 'gradient', 'layout'],
'x-axis-selector': ['color', 'fontSize', 'position', 'axisLabel', 'axisLine', 'splitLine'],
'y-axis-selector': [
'name',
@ -149,13 +149,27 @@ export class BidirectionalHorizontalBar extends G2PlotChartView<
if (basicStyle.gradient) {
const color = basicStyle.colors?.map((ele, index) => {
const tmp = hexColorToRGBA(ele, basicStyle.alpha)
return setGradientColor(tmp, true, 180 - index * 180)
let angle = 180 - index * 180
// 垂直固定角度
if (basicStyle.layout === 'vertical') {
if (index === 0) {
angle = 280
}
if (index === 1) {
angle = 90
}
}
return setGradientColor(tmp, true, angle)
})
options = {
...options,
color
}
}
options = {
...options,
layout: basicStyle.layout
}
return options
}
@ -351,7 +365,7 @@ export class BidirectionalHorizontalBar extends G2PlotChartView<
if (l.show) {
label = {
position: l.position,
layout: [{ type: 'limit-in-canvas' }],
layout: [{ type: 'fixed-overlap' }],
style: {
fill: l.color,
fontSize: l.fontSize