Skip to content

Commit

Permalink
feat: 柱状图和折线图新增维度坐标名称设置
Browse files Browse the repository at this point in the history
  • Loading branch information
liweina committed Mar 18, 2021
1 parent 2d87fd6 commit 3e48792
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/chart-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@
| yAxisMin | 坐标轴刻度最小值 | Array | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.min) |
| yAxisScale | 是否是脱离 0 值比例。设置成 true 后坐标刻度不会强制包含零刻度 | Boolean | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.scale) |
| yAxisName | 坐标轴名称 | Array | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.name) |
| xAxisName | 坐标轴名称 | String | - | 参见[文档](https://echarts.apache.org/zh/option.html#xAxis.name) |
| percentage | 是否是百分比堆叠柱状图,通常结合 `yAxisLabelType` 一起使用 | Boolean | `true`/`false` | 默认 `false` |
| xAxisInverse | X轴方向反向| Boolean | `true`/`false` | 默认 `false` 参见[文档](https://www.echartsjs.com/zh/option.html#xAxis.inverse) |
| yAxisInverse | Y轴方向反向| Boolean/Array | `true`/`false` | 默认 `false` 参见[文档](https://www.echartsjs.com/zh/option.html#yAxis.inverse) |
Expand Down
1 change: 1 addition & 0 deletions docs/chart-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
| yAxisMin | 坐标轴刻度最小值 | Number | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.min) |
| yAxisScale | 是否是脱离 0 值比例。设置成 true 后坐标刻度不会强制包含零刻度 | Boolean | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.scale) |
| yAxisName | 坐标轴名称 | String | - | 参见[文档](https://www.echartsjs.com/option.html#yAxis.name) |
| xAxisName | 坐标轴名称 | String | - | 参见[文档](https://echarts.apache.org/zh/option.html#xAxis.name) |
| percentage | 是否是百分比堆叠面积图,通常结合 `yAxisLabelType` 一起使用 | Boolean | `true`/`false` | 默认 `false` |
| tooltipOptions | 配置tooltip提示框组件 | Object | - | 参见[文档](https://echarts.apache.org/zh/option.html#tooltip) |
| legendOptions | 配置图例组件 | Object | - | 参见[文档](https://echarts.apache.org/zh/option.html#legend) |
Expand Down
6 changes: 5 additions & 1 deletion src/packages/bar/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BarChart extends BaseChart {

// build dimension Axis
static getBarDimAxis (settings) {
const { dimAxisType, dimAxisLineShow, dimAxisLabelShow, dimAxisLabelColor } = settings
const { dimAxisType, dimAxisLineShow, dimAxisLabelShow, dimAxisLabelColor, xAxisName } = settings

const axisItem = {
type: dimAxisType,
Expand All @@ -65,6 +65,10 @@ class BarChart extends BaseChart {
color: Array.isArray(dimAxisLabelColor) ? dimAxisLabelColor[0] : dimAxisLabelColor
}
}
if (xAxisName) {
axisItem.name = xAxisName
}

const disAxis = []
disAxis.push(axisItem)
return disAxis
Expand Down
5 changes: 3 additions & 2 deletions src/packages/line/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LineChart extends BaseChart {
}

static getLineDimAxis ({ settings }) {
const { yAxisType, xAxisLabelShow = true, xAxisLineShow = true, xAxisLabelColor, xAxisInverse = false } = settings
const { yAxisType, xAxisLabelShow = true, xAxisLineShow = true, xAxisLabelColor, xAxisInverse = false, xAxisName } = settings
const type = yAxisType || 'category'
return {
type,
Expand All @@ -42,7 +42,8 @@ class LineChart extends BaseChart {
fontWeight: 400,
color: xAxisLabelColor || null
},
inverse: xAxisInverse
inverse: xAxisInverse,
name: xAxisName !== undefined ? xAxisName : null
}
}

Expand Down

0 comments on commit 3e48792

Please sign in to comment.