Merge pull request #12508 from dataease/pr@dev-v2@refactor_chart_line_legend
Pr@dev v2@refactor chart line legend
This commit is contained in:
commit
336e304292
@ -996,8 +996,9 @@ export default {
|
||||
drag_block_value_axis_left: '左值轴',
|
||||
drag_block_value_axis_right: '右值轴',
|
||||
drag_block_table_data_column: '数据列',
|
||||
drag_block_pie_angel: '扇区角度',
|
||||
drag_block_pie_angle: '扇区角度',
|
||||
drag_block_pie_label: '扇区标签',
|
||||
drag_block_pie_radius: '扇区半径',
|
||||
drag_block_gauge_angel: '指针角度',
|
||||
drag_block_label_value: '值',
|
||||
drag_block_funnel_width: '漏斗层宽',
|
||||
|
||||
@ -25,7 +25,7 @@ const props = defineProps({
|
||||
>{{ t('chart.drag_block_value_axis') }}</span
|
||||
>
|
||||
<span v-else-if="props.view.type && props.view.type.includes('pie')">{{
|
||||
t('chart.drag_block_pie_angel')
|
||||
t('chart.drag_block_pie_angle')
|
||||
}}</span>
|
||||
<span v-else-if="props.view.type && props.view.type.includes('funnel')">{{
|
||||
t('chart.drag_block_funnel_width')
|
||||
|
||||
@ -289,8 +289,11 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
|
||||
}
|
||||
protected configLegend(chart: Chart, options: LineOptions): LineOptions {
|
||||
const optionTmp = super.configLegend(chart, options)
|
||||
if (!optionTmp.legend) {
|
||||
return optionTmp
|
||||
}
|
||||
const xAxisExt = chart.xAxisExt[0]
|
||||
if (optionTmp.legend && xAxisExt?.customSort?.length > 0) {
|
||||
if (xAxisExt?.customSort?.length > 0) {
|
||||
// 图例自定义排序
|
||||
const l = optionTmp.legend
|
||||
const basicStyle = parseJson(chart.customAttr).basicStyle
|
||||
@ -303,11 +306,8 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
|
||||
marker: {
|
||||
symbol: l.marker.symbol,
|
||||
style: {
|
||||
r: 6,
|
||||
fill: 'rgba(0,0,0,0)',
|
||||
lineWidth: 2,
|
||||
lineJoin: 'round',
|
||||
stroke: basicStyle.colors[index % basicStyle.colors.length]
|
||||
r: 4,
|
||||
fill: basicStyle.colors[index % basicStyle.colors.length]
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -322,6 +322,12 @@ export class Line extends G2PlotChartView<LineOptions, G2Line> {
|
||||
legend
|
||||
}
|
||||
}
|
||||
optionTmp.legend.marker.style = style => {
|
||||
return {
|
||||
r: 5,
|
||||
fill: style.stroke
|
||||
}
|
||||
}
|
||||
return optionTmp
|
||||
}
|
||||
protected setupOptions(chart: Chart, options: LineOptions): LineOptions {
|
||||
|
||||
@ -56,7 +56,7 @@ export const PIE_AXIS_CONFIG: AxisConfig = {
|
||||
type: 'd'
|
||||
},
|
||||
yAxis: {
|
||||
name: `${t('chart.drag_block_pie_label')} / ${t('chart.quota')}`,
|
||||
name: `${t('chart.drag_block_pie_angle')} / ${t('chart.quota')}`,
|
||||
type: 'q',
|
||||
limit: 1
|
||||
}
|
||||
|
||||
@ -19,12 +19,21 @@ import { valueFormatter } from '@/views/chart/components/js/formatter'
|
||||
import { Datum } from '@antv/g2plot/esm/types/common'
|
||||
import { add } from 'mathjs'
|
||||
import isEmpty from 'lodash-es/isEmpty'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
const { t } = useI18n()
|
||||
|
||||
export class Rose extends G2PlotChartView<RoseOptions, G2Rose> {
|
||||
axis: AxisType[] = PIE_AXIS_TYPE
|
||||
properties: EditorProperty[] = PIE_EDITOR_PROPERTY
|
||||
propertyInner: EditorPropertyInner = PIE_EDITOR_PROPERTY_INNER
|
||||
axisConfig = PIE_AXIS_CONFIG
|
||||
axisConfig: AxisConfig = {
|
||||
...PIE_AXIS_CONFIG,
|
||||
yAxis: {
|
||||
name: `${t('chart.drag_block_pie_radius')} / ${t('chart.quota')}`,
|
||||
type: 'q',
|
||||
limit: 1
|
||||
}
|
||||
}
|
||||
|
||||
async drawChart(drawOptions: G2PlotDrawOptions<G2Rose>): Promise<G2Rose> {
|
||||
const { chart, container, action } = drawOptions
|
||||
|
||||
Loading…
Reference in New Issue
Block a user