提交 31243cdf 编写于 作者: S sushuang

Fix dataZoom action error when only use one param of 'start' or 'end'.

上级 81291279
......@@ -433,12 +433,8 @@ var DataZoomModel = echarts.extendComponentModel({
* @param {boolean} [ignoreUpdateRangeUsg=false]
*/
setRawRange: function (opt, ignoreUpdateRangeUsg) {
each(['start', 'end', 'startValue', 'endValue'], function (name) {
// If any of those prop is null/undefined, we should alos set
// them, because only one pair between start/end and
// startValue/endValue can work.
this.option[name] = opt[name];
}, this);
setOneSide(opt, this.option, 'start');
setOneSide(opt, this.option, 'end');
!ignoreUpdateRangeUsg && updateRangeUse(this, opt);
},
......@@ -514,6 +510,24 @@ var DataZoomModel = echarts.extendComponentModel({
});
// percentName: 'start' or 'end', valueName: 'startValue' or 'endValue'
function setOneSide(inputParams, option, percentName) {
var names = [percentName, percentName + 'Value'];
var hasValueIdx;
each(names, function (name, index) {
if (inputParams[name] != null) {
option[name] = inputParams[name];
hasValueIdx = index;
}
});
// If only 'start' or 'startValue' is set in inputParams and then assigned
// to option, the other one should be cleared in option. because only one
// pair between start/end and startValue/endValue can work.
if (hasValueIdx != null) {
option[names[1 - hasValueIdx]] = null;
}
}
function retrieveRaw(option) {
var ret = {};
each(
......
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="../dist/echarts.js"></script>
<script src="lib/facePrint.js"></script>
<script src="lib/jquery.min.js"></script>
<link rel="stylesheet" href="reset.css" />
</head>
<body>
<style>
h1 {
line-height: 60px;
background: #360;
text-align: center;
font-weight: bold;
color: #eee;
font-size: 14px;
margin: 0;
}
.chart {
height: 450px;
}
.by-dispatch-action {
padding: 5px;
}
</style>
<div class="by-dispatch-action">
by dispatchAction:
<button id="change-start-value">Change Start Value</button>
<button id="change-end-value">Change Start Value</button>
<button id="first-focus">First Focus</button>
</div>
<div id="main">
<div class="chart" id="chart"></div>
</div>
<script>
$.getJSON('./data/ec-star.json', function (data) {
$('#first-focus').on('click', firstFocus);
$('#change-start-value').on('click', changeStartValue);
$('#change-end-value').on('click', changeEndValue);
var myChart = echarts.init(document.getElementById('chart'));
var minStartValue = '2013-06-06';
var maxEndValue = '2017-10-17';
var currStartValue = '2017-01-01';
var currEndValue = maxEndValue;
var option = {
animationDurationUpdate: 3000,
tooltip: {
trigger: 'axis'
},
xAxis: [{
type: 'time',
boundaryGap: false,
axisLabel:{
textStyle:{
fontSize:14
}
},
splitLine: {
show: false,
lineStyle:{
color:'#f7f7f7'
}
}
}],
yAxis: [{
type: 'value',
name: 'Github Star',
nameGap: 30,
nameTextStyle: {
fontSize: 20
},
axisLabel: {
fontSize: 15
},
splitLine: {
show: true,
lineStyle:{
color:'#f7f7f7'
}
}
}],
grid: {
top: 120,
left: 30,
right: 30,
bottom: 50,
containLabel: true
},
dataZoom: [{
id: 'dz',
type: 'inside',
xAxisIndex: 0,
startValue: currStartValue,
endValue: currEndValue,
minValueSpan: 3600 * 24 * 1000 * 10
}, {
type: 'slider',
xAxisIndex: 0,
startValue: currStartValue,
endValue: currEndValue,
height: 20,
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
handleSize: '90%',
minSpanValue: 3600 * 24 * 1000 * 10
}],
visualMap: {
show: false,
type: 'continuous',
seriesIndex: 0,
min: 0,
max: 23000
},
series: [{
type: 'line',
name: 'Star',
lineStyle: {
normal: {
width: 4
}
},
itemStyle: {
normal: {
borderColor: '#fff',
borderWidth: 2
}
},
showSymbol: false,
symbol: 'circle',
hoverAnimation: false,
symbolSize: 15,
sampling: 'average',
// smooth: true,
// symbol: 'none',
data: data
}]
};
myChart.setOption(option);
$(window).resize(function() {
myChart.resize();
})
// Control -------------------------
function changeStartValue(phase) {
currStartValue = '2014-09-01';
myChart.dispatchAction({
type: 'dataZoom',
id: 'dz',
startValue: currStartValue
});
}
function changeEndValue(phase) {
currEndValue = '2017-02-05';
myChart.dispatchAction({
type: 'dataZoom',
id: 'dz',
endValue: currEndValue
});
}
function firstFocus(phase) {
currStartValue = minStartValue;
currEndValue = '2013-11-06';
myChart.dispatchAction({
type: 'dataZoom',
id: 'dz',
startValue: currStartValue,
endValue: currEndValue
});
}
});
</script>
</body>
</html>
\ No newline at end of file
......@@ -26,13 +26,11 @@
*
* [Caution]:
*
* 1) Modules are not shared between different
* calling of `simpleModuleLoader.load()`.
* 1) Modules are not shared between different calling of `requireES(...)`.
*
* 2) Whether import `*` or `default` is determined
* by module itself. That is, if the module only
* export `default` (like `xxx/SomeClz`), we import
* `default`, otherwise import `*` (like `xxx/util`).
* 2) Whether import `*` or `default` is determined by the module itself.
* That is, if the module (like `xxx/SomeClz`) only export `default` , it
* imports `default`, otherwise (like `xxx/util`) it imports `*`.
*/
/* global define, ActiveXObject */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册