Skip to content

Commit

Permalink
Merge pull request #3 from apache/master
Browse files Browse the repository at this point in the history
Merge some commits from apache/master.
  • Loading branch information
plainheart authored Apr 7, 2020
2 parents 6026bd3 + 5817659 commit e15eaf0
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 42 deletions.
13 changes: 9 additions & 4 deletions src/chart/bar/BarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default echarts.extendChartView({

var drawBackground = seriesModel.get('showBackground', true);
var backgroundModel = seriesModel.getModel('backgroundStyle');
var barBorderRadius = backgroundModel.get('barBorderRadius') || 0;

var bgEls = [];
var oldBgEls = this._backgroundEls || [];
Expand All @@ -140,10 +141,10 @@ export default echarts.extendChartView({
var layout = getLayout[coord.type](data, dataIndex, itemModel);

if (drawBackground) {
var bgLayout = getLayout[coord.type](data, dataIndex, backgroundModel);
var bgLayout = getLayout[coord.type](data, dataIndex);
var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
bgEl.useStyle(backgroundModel.getBarItemStyle());
bgEl.setShape('r', backgroundModel.get('barBorderRadius'));
bgEl.setShape('r', barBorderRadius);
bgEls[dataIndex] = bgEl;
}

Expand Down Expand Up @@ -180,9 +181,11 @@ export default echarts.extendChartView({
if (drawBackground) {
var bgEl = oldBgEls[oldIndex];
bgEl.useStyle(backgroundModel.getBarItemStyle());
bgEl.setShape('r', barBorderRadius);
bgEls[newIndex] = bgEl;

var shape = createBackgroundShape(isHorizontalOrRadial, layout, coord);
var bgLayout = getLayout[coord.type](data, newIndex);
var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
graphic.updateProps(bgEl, { shape: shape }, animationModel, newIndex);
}

Expand Down Expand Up @@ -432,9 +435,11 @@ function removeSector(dataIndex, animationModel, el) {
}

var getLayout = {
// itemModel is only used to get borderWidth, which is not needed
// when calculating bar background layout.
cartesian2d: function (data, dataIndex, itemModel) {
var layout = data.getItemLayout(dataIndex);
var fixedLineWidth = getLineWidth(itemModel, layout);
var fixedLineWidth = itemModel ? getLineWidth(itemModel, layout) : 0;

// fix layout with lineWidth
var signX = layout.width > 0 ? 1 : -1;
Expand Down
37 changes: 14 additions & 23 deletions src/coord/axisHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export function getScaleExtent(scale, model) {

var min = model.getMin();
var max = model.getMax();
var fixMin = min != null;
var fixMax = max != null;
var originalExtent = scale.getExtent();

var axisDataLen;
Expand Down Expand Up @@ -107,6 +105,9 @@ export function getScaleExtent(scale, model) {
});
}

var fixMin = min != null;
var fixMax = max != null;

if (min == null) {
min = scaleType === 'ordinal'
? (axisDataLen ? 0 : NaN)
Expand Down Expand Up @@ -168,7 +169,13 @@ export function getScaleExtent(scale, model) {
}
}

return [min, max];
return {
extent: [min, max],
// "fix" means "fixed", the value should not be
// changed in the subsequent steps.
fixMin: fixMin,
fixMax: fixMax
};
}

function adjustScaleForOverflow(min, max, model, barWidthAndOffset) {
Expand Down Expand Up @@ -207,24 +214,8 @@ function adjustScaleForOverflow(min, max, model, barWidthAndOffset) {
}

export function niceScaleExtent(scale, model) {
var extent = getScaleExtent(scale, model);
var min = model.getMin();
var max = model.getMax();
var originalExtent = scale.getExtent();

if (typeof min === 'function') {
min = min({
min: originalExtent[0],
max: originalExtent[1]
});
}

if (typeof max === 'function') {
max = max({
min: originalExtent[0],
max: originalExtent[1]
});
}
var extentInfo = getScaleExtent(scale, model);
var extent = extentInfo.extent;

var splitNumber = model.get('splitNumber');

Expand All @@ -236,8 +227,8 @@ export function niceScaleExtent(scale, model) {
scale.setExtent(extent[0], extent[1]);
scale.niceExtent({
splitNumber: splitNumber,
fixMin: min != null,
fixMax: max != null,
fixMin: extentInfo.fixMin,
fixMax: extentInfo.fixMin,
minInterval: (scaleType === 'interval' || scaleType === 'time')
? model.get('minInterval') : null,
maxInterval: (scaleType === 'interval' || scaleType === 'time')
Expand Down
2 changes: 1 addition & 1 deletion src/coord/radar/Radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Radar.prototype.update = function (ecModel, api) {
}
// Force all the axis fixing the maxSplitNumber.
zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
var rawExtent = getScaleExtent(indicatorAxis.scale, indicatorAxis.model);
var rawExtent = getScaleExtent(indicatorAxis.scale, indicatorAxis.model).extent;
niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);

var axisModel = indicatorAxis.model;
Expand Down
18 changes: 17 additions & 1 deletion test/bar-background.html
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@
series: [{
data: [110, 120, 150, 250, 350, 400, 500, 600],
type: 'bar',
itemStyle: {
barBorderWidth: 20,
barBorderColor: 'rgba(50,50,50,0.3)'
},
showBackground: true,
backgroundStyle: {
color: 'green',
Expand All @@ -545,7 +549,19 @@
option: option,
title: [
'background barBorderRadius'
]
],
buttons: [{
text: 'update barBorderRadius to [30, 40, 0, 60]',
onclick: function () {
chart.setOption({
series: {
backgroundStyle: {
barBorderRadius: [30, 40, 0, 60]
}
}
});
}
}]
});
});
</script>
Expand Down
117 changes: 104 additions & 13 deletions test/min-max-function.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,29 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="lib/jquery.min.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/testHelper.js"></script>
<link rel="stylesheet" href="lib/reset.css" />
</head>
<body>
<style>
html, body, .chart {
width: 100%;
margin: 0;
}

.chart {
height: 400px;
}
</style>

<div id="chart-1" class="chart"></div>
<div id="main1"></div>


<script>

require([
'echarts'
// 'echarts/chart/bar',
// 'echarts/chart/line',
// 'echarts/component/tooltip',
// 'echarts/component/dataZoom',
// 'echarts/component/markPoint',
// 'echarts/component/toolbox',
// 'zrender/vml/vml'
], function (echarts) {

var chart = echarts.init(document.getElementById('chart-1'));
Expand Down Expand Up @@ -125,5 +121,100 @@
});
});
</script>




<script>

require([
'echarts'
], function (echarts) {
function xAxisData() { return ['a', 'b', 'c']; };
function seriesData() { return [12, 32, 44]; };
var gridWidth = 100;
var gridBottom = 80;
var gridGap = 50;
var gridCurrLeft = gridGap;
var nameTextStyle = {align: 'left'};

function getGridLeft() {
var left = gridCurrLeft;
gridCurrLeft += gridWidth + gridGap;
return left;
}

var option = {
dataZoom: [
{type: 'inside', yAxisIndex: 1},
{type: 'inside', yAxisIndex: 3}
],
grid: [
{width: gridWidth, bottom: gridBottom, left: getGridLeft()},
{width: gridWidth, bottom: gridBottom, left: getGridLeft()},
{width: gridWidth, bottom: gridBottom, left: getGridLeft()},
{width: gridWidth, bottom: gridBottom, left: getGridLeft()}
],
xAxis: [
{gridIndex: 0, data: xAxisData()},
{gridIndex: 1, data: xAxisData()},
{gridIndex: 2, data: xAxisData()},
{gridIndex: 3, data: xAxisData()}
],
yAxis: [{
gridIndex: 0,
name: 'y min/max:\nfunction return null\nno dataZoom',
nameTextStyle: nameTextStyle,
min: function (param) {
return null;
},
max: function (param) {
return null;
}
}, {
gridIndex: 1,
name: 'y min/max:\nfunction return null\ny inside dataZoom',
nameTextStyle: nameTextStyle,
min: function (param) {
return null;
},
max: function (param) {
return null;
}
}, {
gridIndex: 2,
name: 'y min/max:\nnull\nno dataZoom',
nameTextStyle: nameTextStyle,
min: null,
max: null
}, {
gridIndex: 3,
name: 'y min/max:\nnull\ny inside dataZoom',
nameTextStyle: nameTextStyle,
min: null,
max: null
}],
series: [
{type: 'scatter', data: seriesData(), xAxisIndex: 0, yAxisIndex: 0},
{type: 'scatter', data: seriesData(), xAxisIndex: 1, yAxisIndex: 1},
{type: 'scatter', data: seriesData(), xAxisIndex: 2, yAxisIndex: 2},
{type: 'scatter', data: seriesData(), xAxisIndex: 3, yAxisIndex: 3},
]
};

var chart = testHelper.create(echarts, 'main1', {
title: [
'Y range should be all the same',
'dataZoom should be normal'
],
option: option
});

});

</script>



</body>
</html>
1 change: 1 addition & 0 deletions test/runTest/actions/__meta__.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"axis-style": 2,
"axisPosition": 2,
"bar": 2,
"bar-background": 3,
"bar-label-rotation": 2,
"bar-large": 2,
"bar-overflow-time-plot": 3,
Expand Down
1 change: 1 addition & 0 deletions test/runTest/actions/bar-background.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"name":"Action 1","ops":[{"type":"mousemove","time":560,"x":793,"y":238},{"type":"mousemove","time":761,"x":444,"y":258},{"type":"mousewheel","time":1526,"x":444,"y":258,"deltaY":1},{"type":"mousewheel","time":1592,"x":444,"y":258,"deltaY":24},{"type":"mousewheel","time":1626,"x":444,"y":258,"deltaY":10},{"type":"mousewheel","time":1671,"x":444,"y":258,"deltaY":11},{"type":"mousewheel","time":1691,"x":444,"y":258,"deltaY":8},{"type":"mousewheel","time":1713,"x":444,"y":258,"deltaY":3},{"type":"mousewheel","time":1732,"x":444,"y":258,"deltaY":2},{"type":"mousewheel","time":1753,"x":444,"y":258,"deltaY":3},{"type":"mousewheel","time":3060,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":3095,"x":444,"y":258,"deltaY":-9},{"type":"mousewheel","time":3112,"x":444,"y":258,"deltaY":-6},{"type":"mousewheel","time":3133,"x":444,"y":258,"deltaY":-8},{"type":"mousewheel","time":3152,"x":444,"y":258,"deltaY":-13},{"type":"mousewheel","time":3171,"x":444,"y":258,"deltaY":-10},{"type":"mousewheel","time":3212,"x":444,"y":258,"deltaY":-19},{"type":"mousewheel","time":3230,"x":444,"y":258,"deltaY":-6},{"type":"mousewheel","time":3252,"x":444,"y":258,"deltaY":-9},{"type":"mousewheel","time":3272,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3314,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3359,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":3392,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":3443,"x":444,"y":258,"deltaY":-12},{"type":"mousewheel","time":3464,"x":444,"y":258,"deltaY":-11},{"type":"mousewheel","time":3484,"x":444,"y":258,"deltaY":-11},{"type":"mousewheel","time":3507,"x":444,"y":258,"deltaY":-6},{"type":"mousewheel","time":3558,"x":444,"y":258,"deltaY":-18},{"type":"mousewheel","time":3579,"x":444,"y":258,"deltaY":-7},{"type":"mousewheel","time":3600,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3621,"x":444,"y":258,"deltaY":-6},{"type":"mousewheel","time":3672,"x":444,"y":258,"deltaY":-6},{"type":"mousewheel","time":3696,"x":444,"y":258,"deltaY":-13},{"type":"mousewheel","time":3717,"x":444,"y":258,"deltaY":-5},{"type":"mousewheel","time":3738,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3762,"x":444,"y":258,"deltaY":-8},{"type":"mousewheel","time":3783,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3806,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3830,"x":444,"y":258,"deltaY":-7},{"type":"mousewheel","time":3852,"x":444,"y":258,"deltaY":-3},{"type":"mousewheel","time":3874,"x":444,"y":258,"deltaY":-3},{"type":"mousewheel","time":3897,"x":444,"y":258,"deltaY":-5},{"type":"mousewheel","time":3921,"x":444,"y":258,"deltaY":-2},{"type":"mousewheel","time":3943,"x":444,"y":258,"deltaY":-4},{"type":"mousewheel","time":3964,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":3989,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":4012,"x":444,"y":258,"deltaY":-2},{"type":"mousewheel","time":4034,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":4060,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":4082,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":4105,"x":444,"y":258,"deltaY":-1},{"type":"mousewheel","time":4130,"x":444,"y":258,"deltaY":-1},{"type":"mousemove","time":4859,"x":444,"y":256},{"type":"mousemove","time":5060,"x":431,"y":97},{"type":"mousemove","time":5260,"x":432,"y":66},{"type":"mousemove","time":5471,"x":426,"y":52},{"type":"mousemove","time":5687,"x":424,"y":49},{"type":"mousedown","time":5735,"x":424,"y":49},{"type":"mouseup","time":5744,"x":424,"y":49},{"time":5745,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":6792,"x":415,"y":49},{"type":"mousemove","time":6992,"x":339,"y":52},{"type":"mousemove","time":7192,"x":321,"y":56},{"type":"mousemove","time":7393,"x":302,"y":48},{"type":"mousedown","time":7521,"x":302,"y":48},{"type":"mouseup","time":7529,"x":302,"y":48},{"time":7530,"delay":400,"type":"screenshot-auto"},{"type":"mousedown","time":8738,"x":302,"y":48},{"type":"mouseup","time":8761,"x":302,"y":48},{"time":8762,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":9110,"x":303,"y":48},{"type":"mousemove","time":9323,"x":378,"y":47},{"type":"mousemove","time":9532,"x":424,"y":46},{"type":"mousemove","time":9739,"x":430,"y":47},{"type":"mousedown","time":9859,"x":430,"y":47},{"type":"mouseup","time":9868,"x":430,"y":47},{"time":9869,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":11333,"x":430,"y":47},{"type":"mousemove","time":11533,"x":434,"y":49},{"type":"mousemove","time":11733,"x":442,"y":49},{"type":"mousemove","time":11933,"x":485,"y":45},{"type":"mousemove","time":12142,"x":487,"y":45},{"type":"mousemove","time":12350,"x":544,"y":49},{"type":"mousemove","time":12550,"x":556,"y":53}],"scrollY":0,"scrollX":0,"timestamp":1585829707406},{"name":"Action 2","ops":[{"type":"mousemove","time":614,"x":748,"y":275},{"type":"mousemove","time":816,"x":498,"y":220},{"type":"mousemove","time":1023,"x":404,"y":189},{"type":"mousemove","time":1232,"x":379,"y":164},{"type":"mousemove","time":1432,"x":387,"y":168},{"type":"mousemove","time":1641,"x":388,"y":168},{"type":"mousedown","time":1789,"x":388,"y":168},{"type":"mouseup","time":1798,"x":388,"y":168},{"time":1799,"delay":400,"type":"screenshot-auto"},{"type":"mousedown","time":2723,"x":388,"y":168},{"type":"mouseup","time":2730,"x":388,"y":168},{"time":2731,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":3082,"x":386,"y":168},{"type":"mousemove","time":3292,"x":340,"y":172},{"type":"mousemove","time":3509,"x":340,"y":172},{"type":"mousedown","time":3560,"x":340,"y":172},{"type":"mouseup","time":3569,"x":340,"y":172},{"time":3570,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":3798,"x":342,"y":172},{"type":"mousemove","time":3998,"x":410,"y":174},{"type":"mousemove","time":4198,"x":436,"y":175},{"type":"mousemove","time":4407,"x":438,"y":175},{"type":"mousedown","time":4441,"x":438,"y":175},{"type":"mouseup","time":4449,"x":438,"y":175},{"time":4450,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":4631,"x":436,"y":175},{"type":"mousemove","time":4832,"x":404,"y":173},{"type":"mousedown","time":5041,"x":398,"y":173},{"type":"mouseup","time":5050,"x":398,"y":173},{"time":5051,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":5070,"x":398,"y":173},{"type":"mousemove","time":6638,"x":396,"y":173},{"type":"mousemove","time":6839,"x":360,"y":170},{"type":"mousemove","time":7039,"x":353,"y":172},{"type":"mousedown","time":7197,"x":353,"y":172},{"type":"mouseup","time":7205,"x":353,"y":172},{"time":7206,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":7388,"x":356,"y":172},{"type":"mousemove","time":7599,"x":387,"y":170},{"type":"mousedown","time":7733,"x":387,"y":170},{"type":"mouseup","time":7743,"x":387,"y":170},{"time":7744,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":7938,"x":390,"y":170},{"type":"mousemove","time":8139,"x":432,"y":169},{"type":"mousedown","time":8285,"x":432,"y":169},{"type":"mouseup","time":8294,"x":432,"y":169},{"time":8295,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":8606,"x":436,"y":169},{"type":"mousemove","time":8818,"x":668,"y":237},{"type":"mousemove","time":9034,"x":713,"y":263},{"type":"mousedown","time":9075,"x":713,"y":263},{"type":"mouseup","time":9087,"x":713,"y":263},{"time":9088,"delay":400,"type":"screenshot-auto"}],"scrollY":2628,"scrollX":0,"timestamp":1585829732163},{"name":"Action 3","ops":[{"type":"mousemove","time":677,"x":350,"y":205},{"type":"mousemove","time":885,"x":269,"y":204},{"type":"mousemove","time":1093,"x":240,"y":202},{"type":"mousemove","time":1293,"x":227,"y":300},{"type":"mousemove","time":1493,"x":226,"y":324},{"type":"mousemove","time":1693,"x":196,"y":190},{"type":"mousemove","time":1901,"x":193,"y":177},{"type":"mousemove","time":2210,"x":193,"y":177},{"type":"mousedown","time":2634,"x":193,"y":177},{"type":"mouseup","time":2735,"x":193,"y":177},{"time":2736,"delay":400,"type":"screenshot-auto"},{"type":"mousedown","time":4829,"x":193,"y":177},{"type":"mouseup","time":4837,"x":193,"y":177},{"time":4838,"delay":400,"type":"screenshot-auto"}],"scrollY":3084,"scrollX":0,"timestamp":1585829746508}]

0 comments on commit e15eaf0

Please sign in to comment.