diff --git a/src/components/charts/G2/components/Area/base.vue b/src/components/charts/G2/components/Area/base.vue index c7b08880..8b816d8c 100644 --- a/src/components/charts/G2/components/Area/base.vue +++ b/src/components/charts/G2/components/Area/base.vue @@ -16,13 +16,21 @@ export default { this.creatChart() // 本组件的特殊设置 this.chart.source(this.data) - this.chart.axis('x', { - label: { - offset: 12 + this.chart.scale({ + y: { + min: 0 + }, + x: { + range: [0, 1] } }) - this.chart.coord().transpose() - this.chart.interval().position('x*y') + this.chart.tooltip({ + crosshairs: { + type: 'line' + } + }) + this.chart.area().position('x*y') + this.chart.line().position('x*y').size(2) // 渲染图表 this.chart.render() }, diff --git a/src/mock/chart/G2Area.js b/src/mock/chart/G2Area.js index d4d3ba2d..7fb99b85 100644 --- a/src/mock/chart/G2Area.js +++ b/src/mock/chart/G2Area.js @@ -6,7 +6,17 @@ Mock.mock('/api/chart/G2Area', 'post', ({body, type, url}) => { switch (_body.type) { // 基础折线图 case 'base': { - return fn.returnMaker(['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月'].map(x => ({x, y: fn.r()}))) + let last = 0 + const data = ['3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月'].map(x => ({ + x, + y: 0 + })).map(e => { + e.y = last + fn.r() + last = e.y + return e + }) + last = 0 + return fn.returnMaker(data) } default: return {} diff --git a/src/pages/demo/chart/index/index.vue b/src/pages/demo/chart/index/index.vue index 6bacb95c..210d6f3b 100644 --- a/src/pages/demo/chart/index/index.vue +++ b/src/pages/demo/chart/index/index.vue @@ -111,8 +111,7 @@ export default { { api: {url: '/api/chart/G2Area', data: {type: 'base'}}, refName: 'G2AreaBase', - data: [], - padding: [30, 30, 30, 30] + data: [] } ], layout: {