Skip to content

Commit 9d0c894

Browse files
Merge pull request #166 from vueblocks/develop
feat: 柱状图新增yAxisPointerType(纵坐标指示器类型)配置项
2 parents 1d7c07f + 6d2d0bc commit 9d0c894

File tree

6 files changed

+85
-24
lines changed

6 files changed

+85
-24
lines changed

docs/chart-bar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,4 @@
767767
| markLine | 图表标线 | Object | - | 参见[文档](https://echarts.apache.org/v4/zh/option.html#series-line.markLine) |
768768
| markArea | 图表标域 | Object | - | 参见[文档](https://echarts.apache.org/v4/zh/option.html#series-line.markArea) |
769769
| xAxisLabelRotate | 横坐标轴刻度标签旋转角度| Number | -90度到90度 | 默认 0 | https://echarts.apache.org/zh/option.html#xAxis.axisLabel.rotate |
770+
| yAxisPointerType | 纵坐标指示器类型 | String | `line`/`shadow`/`none` | 参见[文档](https://echarts.apache.org/v4/zh/option.html#axisPointer.type) |

lib/ve-charts.common.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,6 @@ module.exports = JSON.parse("{\"72\":\"朝阳区\",\"78\":\"黄浦区\",\"83\":\
256256

257257
/***/ }),
258258

259-
/***/ "296b":
260-
/***/ (function(module, exports) {
261-
262-
module.exports = require("echarts");
263-
264-
/***/ }),
265-
266259
/***/ "2f74":
267260
/***/ (function(module, __webpack_exports__, __webpack_require__) {
268261

@@ -1802,6 +1795,13 @@ module.exports = function(originalModule) {
18021795
};
18031796

18041797

1798+
/***/ }),
1799+
1800+
/***/ "ddb4":
1801+
/***/ (function(module, exports) {
1802+
1803+
module.exports = require("echarts");
1804+
18051805
/***/ }),
18061806

18071807
/***/ "dff1":
@@ -1916,7 +1916,7 @@ if (typeof window !== 'undefined') {
19161916
/* harmony default export */ var setPublicPath = (null);
19171917

19181918
// EXTERNAL MODULE: external "echarts"
1919-
var external_echarts_ = __webpack_require__("296b");
1919+
var external_echarts_ = __webpack_require__("ddb4");
19201920
var external_echarts_default = /*#__PURE__*/__webpack_require__.n(external_echarts_);
19211921

19221922
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"45371285-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/HocEcharts.vue?vue&type=template&id=1a0a63b4&
@@ -7729,10 +7729,14 @@ var LoadingChart_component = normalizeComponent(
77297729
// 当未配置 seriesOption 系列配置时
77307730
if (Object.keys(this.seriesOption).length === 0) return series
77317731

7732-
// 合并 series 配置
7732+
// 生成 series
77337733
for (const [key, opt] of Object.entries(this.seriesOption)) {
77347734
const _idx = series.findIndex(v => v.name === key)
7735-
if (_idx > -1) lodash_es_merge(series[_idx], opt)
7735+
if (_idx > -1) { // 存在series时,合并配置项
7736+
lodash_es_merge(series[_idx], opt)
7737+
} else if (opt.type) { // 不存在series时,如果包含type,新建系列
7738+
series[series.length] = opt
7739+
}
77367740
}
77377741
return series
77387742
},
@@ -7889,7 +7893,16 @@ class chart_BarChart extends src_BaseChart {
78897893

78907894
// build dimension Axis
78917895
static getBarDimAxis (settings) {
7892-
const { dimAxisType, dimAxisLineShow, dimAxisLabelShow, dimAxisLabelColor, xAxisName, xAxisSplitLine, dimAxisLabelRotate } = settings
7896+
const {
7897+
dimAxisType,
7898+
dimAxisLineShow,
7899+
dimAxisLabelShow,
7900+
dimAxisLabelColor,
7901+
xAxisName,
7902+
xAxisSplitLine,
7903+
dimAxisLabelRotate,
7904+
dimAxisPointerType
7905+
} = settings
78937906

78947907
const axisItem = {
78957908
type: dimAxisType,
@@ -7905,6 +7918,10 @@ class chart_BarChart extends src_BaseChart {
79057918
fontWeight: 400,
79067919
color: Array.isArray(dimAxisLabelColor) ? dimAxisLabelColor[0] : dimAxisLabelColor,
79077920
rotate: dimAxisLabelRotate
7921+
},
7922+
axisPointer: {
7923+
show: true,
7924+
type: dimAxisPointerType
79087925
}
79097926
}
79107927
if (xAxisName) {
@@ -8036,7 +8053,7 @@ class chart_BarChart extends src_BaseChart {
80368053

80378054
// deviated from markLine/markArea of the series
80388055
if (markLine || markArea) {
8039-
series.push({ type: 'bar', markLine, markArea })
8056+
series.push({ type: 'bar', name: '', data: [], markLine, markArea })
80408057
}
80418058

80428059
measures.forEach(({ name }) => {
@@ -8088,7 +8105,9 @@ class chart_BarChart extends src_BaseChart {
80888105
xAxisLineShow = true,
80898106
xAxisLabelColor = null,
80908107
xAxisLabelRotate = 0,
8091-
yAxisLabelRotate = 0
8108+
yAxisLabelRotate = 0,
8109+
xAxisPointerType,
8110+
yAxisPointerType
80928111
} = settings
80938112

80948113
// 默认柱状图
@@ -8111,6 +8130,7 @@ class chart_BarChart extends src_BaseChart {
81118130
settings.dimAxisLineShow = (isBar ? yAxisLineShow : xAxisLineShow)
81128131
settings.dimAxisLabelColor = (isBar ? yAxisLabelColor : xAxisLabelColor)
81138132
settings.dimAxisLabelRotate = isBar ? yAxisLabelRotate : xAxisLabelRotate
8133+
settings.dimAxisPointerType = isBar ? yAxisPointerType : xAxisPointerType
81148134

81158135
// 如果设置了双Y轴,将双Y轴统一设置 meaAxisType
81168136
if (defaultMeaAxisType.length > settings.meaAxisType.length) {

lib/ve-charts.umd.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7738,10 +7738,14 @@ var LoadingChart_component = normalizeComponent(
77387738
// 当未配置 seriesOption 系列配置时
77397739
if (Object.keys(this.seriesOption).length === 0) return series
77407740

7741-
// 合并 series 配置
7741+
// 生成 series
77427742
for (const [key, opt] of Object.entries(this.seriesOption)) {
77437743
const _idx = series.findIndex(v => v.name === key)
7744-
if (_idx > -1) lodash_es_merge(series[_idx], opt)
7744+
if (_idx > -1) { // 存在series时,合并配置项
7745+
lodash_es_merge(series[_idx], opt)
7746+
} else if (opt.type) { // 不存在series时,如果包含type,新建系列
7747+
series[series.length] = opt
7748+
}
77457749
}
77467750
return series
77477751
},
@@ -7898,7 +7902,16 @@ class chart_BarChart extends src_BaseChart {
78987902

78997903
// build dimension Axis
79007904
static getBarDimAxis (settings) {
7901-
const { dimAxisType, dimAxisLineShow, dimAxisLabelShow, dimAxisLabelColor, xAxisName, xAxisSplitLine, dimAxisLabelRotate } = settings
7905+
const {
7906+
dimAxisType,
7907+
dimAxisLineShow,
7908+
dimAxisLabelShow,
7909+
dimAxisLabelColor,
7910+
xAxisName,
7911+
xAxisSplitLine,
7912+
dimAxisLabelRotate,
7913+
dimAxisPointerType
7914+
} = settings
79027915

79037916
const axisItem = {
79047917
type: dimAxisType,
@@ -7914,6 +7927,10 @@ class chart_BarChart extends src_BaseChart {
79147927
fontWeight: 400,
79157928
color: Array.isArray(dimAxisLabelColor) ? dimAxisLabelColor[0] : dimAxisLabelColor,
79167929
rotate: dimAxisLabelRotate
7930+
},
7931+
axisPointer: {
7932+
show: true,
7933+
type: dimAxisPointerType
79177934
}
79187935
}
79197936
if (xAxisName) {
@@ -8045,7 +8062,7 @@ class chart_BarChart extends src_BaseChart {
80458062

80468063
// deviated from markLine/markArea of the series
80478064
if (markLine || markArea) {
8048-
series.push({ type: 'bar', markLine, markArea })
8065+
series.push({ type: 'bar', name: '', data: [], markLine, markArea })
80498066
}
80508067

80518068
measures.forEach(({ name }) => {
@@ -8097,7 +8114,9 @@ class chart_BarChart extends src_BaseChart {
80978114
xAxisLineShow = true,
80988115
xAxisLabelColor = null,
80998116
xAxisLabelRotate = 0,
8100-
yAxisLabelRotate = 0
8117+
yAxisLabelRotate = 0,
8118+
xAxisPointerType,
8119+
yAxisPointerType
81018120
} = settings
81028121

81038122
// 默认柱状图
@@ -8120,6 +8139,7 @@ class chart_BarChart extends src_BaseChart {
81208139
settings.dimAxisLineShow = (isBar ? yAxisLineShow : xAxisLineShow)
81218140
settings.dimAxisLabelColor = (isBar ? yAxisLabelColor : xAxisLabelColor)
81228141
settings.dimAxisLabelRotate = isBar ? yAxisLabelRotate : xAxisLabelRotate
8142+
settings.dimAxisPointerType = isBar ? yAxisPointerType : xAxisPointerType
81238143

81248144
// 如果设置了双Y轴,将双Y轴统一设置 meaAxisType
81258145
if (defaultMeaAxisType.length > settings.meaAxisType.length) {

lib/ve-charts.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mixins/core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,14 @@ export default {
185185
// 当未配置 seriesOption 系列配置时
186186
if (Object.keys(this.seriesOption).length === 0) return series
187187

188-
// 合并 series 配置
188+
// 生成 series
189189
for (const [key, opt] of Object.entries(this.seriesOption)) {
190190
const _idx = series.findIndex(v => v.name === key)
191-
if (_idx > -1) merge(series[_idx], opt)
191+
if (_idx > -1) { // 存在series时,合并配置项
192+
merge(series[_idx], opt)
193+
} else if (opt.type) { // 不存在series时,如果包含type,新建系列
194+
series[series.length] = opt
195+
}
192196
}
193197
return series
194198
},

src/packages/bar/chart.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ class BarChart extends BaseChart {
4848

4949
// build dimension Axis
5050
static getBarDimAxis (settings) {
51-
const { dimAxisType, dimAxisLineShow, dimAxisLabelShow, dimAxisLabelColor, xAxisName, xAxisSplitLine, dimAxisLabelRotate } = settings
51+
const {
52+
dimAxisType,
53+
dimAxisLineShow,
54+
dimAxisLabelShow,
55+
dimAxisLabelColor,
56+
xAxisName,
57+
xAxisSplitLine,
58+
dimAxisLabelRotate,
59+
dimAxisPointerType
60+
} = settings
5261

5362
const axisItem = {
5463
type: dimAxisType,
@@ -64,6 +73,10 @@ class BarChart extends BaseChart {
6473
fontWeight: 400,
6574
color: Array.isArray(dimAxisLabelColor) ? dimAxisLabelColor[0] : dimAxisLabelColor,
6675
rotate: dimAxisLabelRotate
76+
},
77+
axisPointer: {
78+
show: true,
79+
type: dimAxisPointerType
6780
}
6881
}
6982
if (xAxisName) {
@@ -195,7 +208,7 @@ class BarChart extends BaseChart {
195208

196209
// deviated from markLine/markArea of the series
197210
if (markLine || markArea) {
198-
series.push({ type: 'bar', markLine, markArea })
211+
series.push({ type: 'bar', name: '', data: [], markLine, markArea })
199212
}
200213

201214
measures.forEach(({ name }) => {
@@ -247,7 +260,9 @@ class BarChart extends BaseChart {
247260
xAxisLineShow = true,
248261
xAxisLabelColor = null,
249262
xAxisLabelRotate = 0,
250-
yAxisLabelRotate = 0
263+
yAxisLabelRotate = 0,
264+
xAxisPointerType,
265+
yAxisPointerType
251266
} = settings
252267

253268
// 默认柱状图
@@ -270,6 +285,7 @@ class BarChart extends BaseChart {
270285
settings.dimAxisLineShow = (isBar ? yAxisLineShow : xAxisLineShow)
271286
settings.dimAxisLabelColor = (isBar ? yAxisLabelColor : xAxisLabelColor)
272287
settings.dimAxisLabelRotate = isBar ? yAxisLabelRotate : xAxisLabelRotate
288+
settings.dimAxisPointerType = isBar ? yAxisPointerType : xAxisPointerType
273289

274290
// 如果设置了双Y轴,将双Y轴统一设置 meaAxisType
275291
if (defaultMeaAxisType.length > settings.meaAxisType.length) {

0 commit comments

Comments
 (0)