提交 0e908040 编写于 作者: P pah100

add restore

上级 dd1b353a
......@@ -7,4 +7,5 @@ define(function (require) {
require('./toolbox/feature/MagicType');
require('./toolbox/feature/DataView');
require('./toolbox/feature/DataZoom');
require('./toolbox/feature/Restore');
});
\ No newline at end of file
......@@ -33,7 +33,7 @@ define(function(require) {
* @private
* @type {Object}
*/
this._activeMap = {zoom: false, back: false};
this._selectedMap = {zoom: false, back: false};
/**
* [{key: dataZoomId, value: {dataZoomId, range}}, ...]
......@@ -46,7 +46,7 @@ define(function(require) {
}
DataZoom.defaultOption = {
show: true,
show: false,
type: [],
// Icon group
icon: {
......@@ -89,7 +89,7 @@ define(function(require) {
var handlers = {
zoom: function (controllerGroup, ecModel, api) {
var isZoomActive = this._activeMap.zoom = !this._activeMap.zoom;
var isZoomActive = this._selectedMap.zoom = !this._selectedMap.zoom;
var zr = api.getZr();
if (isZoomActive) {
......@@ -117,6 +117,10 @@ define(function(require) {
}
};
proto.getSelectedMap = function () {
return zrUtil.clone(this._selectedMap);
};
/**
* @private
*/
......@@ -140,8 +144,10 @@ define(function(require) {
proto._disposeController = function () {
var controller = this._controller;
controller.off('selected');
controller.dispose();
if (controller) {
controller.off('selected');
controller.dispose();
}
};
function prepareCoordInfo(grid, ecModel) {
......@@ -272,7 +278,7 @@ define(function(require) {
history.push(newSnapshot);
// Update state of back button.
this._activeMap.back = history.length <= 1;
this._selectedMap.back = history.length <= 1;
};
/**
......@@ -284,7 +290,7 @@ define(function(require) {
history.length > 1 && history.pop();
// Update state of back button.
this._activeMap.back = history.length <= 1;
this._selectedMap.back = history.length <= 1;
// Find top for all dataZoom.
var snapshot = {};
......
define(function(require) {
'use strict';
function Restore(model) {
this.model = model;
}
Restore.defaultOption = {
show: false,
type: [],
icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5',
title: '还原'
};
var proto = Restore.prototype;
proto.onclick = function (ecModel, api, type) {
api.dispatchAction({
type: 'restore',
from: this.uid
});
};
require('../featureManager').register('restore', Restore);
require('../../../echarts').registerAction(
{type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
function (payload, ecModel) {
ecModel.resetOption('recreate');
}
);
return Restore;
});
\ No newline at end of file
......@@ -56,6 +56,7 @@ define(function (require) {
/**
* @param {string} type null/undefined: reset all.
* 'recreate': force recreate all.
* 'timeline': only reset timeline option
* 'media': only reset media query option
* @return {boolean} Whether option changed.
......@@ -64,10 +65,10 @@ define(function (require) {
var optionChanged = false;
var optionManager = this._optionManager;
if (!type) {
if (!type || type === 'recreate') {
var baseOption = optionManager.mountOption();
if (!this.option) {
if (!this.option || type === 'recreate') {
initBase.call(this, baseOption);
}
else {
......@@ -81,12 +82,12 @@ define(function (require) {
this.restoreData();
}
if (!type || type === 'timeline') {
if (!type || type === 'recreate' || type === 'timeline') {
var partialOption = optionManager.getTimelineOption(this);
partialOption && (this.mergeOption(partialOption), optionChanged = true);
}
if (!type || type === 'media') {
if (!type || type === 'recreate' || type === 'media') {
var partialOption = optionManager.getMediaOption(this, this._api);
partialOption && (this.mergeOption(partialOption), optionChanged = true);
}
......@@ -829,7 +830,7 @@ define(function (require) {
return componentOption.id
// FIXME
// Where to put this constant.
&& (componentOption.id + '').indexOf('\0_ec_\0') === 0
&& (componentOption.id + '').indexOf('\0_ec_\0') === 0;
}
/**
......
......@@ -55,7 +55,8 @@
// y: 'bottom',
feature: {
dataView: {},
dataZoom: {},
dataZoom: {show: true},
restore: {show: true},
saveAsImage: {}
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册