123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- var zrUtil = require("zrender/lib/core/util");
- var SymbolDraw = require("../../chart/helper/SymbolDraw");
- var numberUtil = require("../../util/number");
- var List = require("../../data/List");
- var markerHelper = require("./markerHelper");
- var MarkerView = require("./MarkerView");
- function updateMarkerLayout(mpData, seriesModel, api) {
- var coordSys = seriesModel.coordinateSystem;
- mpData.each(function (idx) {
- var itemModel = mpData.getItemModel(idx);
- var point;
- var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
- var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
- if (!isNaN(xPx) && !isNaN(yPx)) {
- point = [xPx, yPx];
- }
- else if (seriesModel.getMarkerPosition) {
-
- point = seriesModel.getMarkerPosition(mpData.getValues(mpData.dimensions, idx));
- } else if (coordSys) {
- var x = mpData.get(coordSys.dimensions[0], idx);
- var y = mpData.get(coordSys.dimensions[1], idx);
- point = coordSys.dataToPoint([x, y]);
- }
- if (!isNaN(xPx)) {
- point[0] = xPx;
- }
- if (!isNaN(yPx)) {
- point[1] = yPx;
- }
- mpData.setItemLayout(idx, point);
- });
- }
- var _default = MarkerView.extend({
- type: 'markPoint',
-
-
-
-
-
-
-
-
-
- updateTransform: function (markPointModel, ecModel, api) {
- ecModel.eachSeries(function (seriesModel) {
- var mpModel = seriesModel.markPointModel;
- if (mpModel) {
- updateMarkerLayout(mpModel.getData(), seriesModel, api);
- this.markerGroupMap.get(seriesModel.id).updateLayout(mpModel);
- }
- }, this);
- },
- renderSeries: function (seriesModel, mpModel, ecModel, api) {
- var coordSys = seriesModel.coordinateSystem;
- var seriesId = seriesModel.id;
- var seriesData = seriesModel.getData();
- var symbolDrawMap = this.markerGroupMap;
- var symbolDraw = symbolDrawMap.get(seriesId) || symbolDrawMap.set(seriesId, new SymbolDraw());
- var mpData = createList(coordSys, seriesModel, mpModel);
- mpModel.setData(mpData);
- updateMarkerLayout(mpModel.getData(), seriesModel, api);
- mpData.each(function (idx) {
- var itemModel = mpData.getItemModel(idx);
- var symbol = itemModel.getShallow('symbol');
- var symbolSize = itemModel.getShallow('symbolSize');
- var symbolRotate = itemModel.getShallow('symbolRotate');
- var isFnSymbol = zrUtil.isFunction(symbol);
- var isFnSymbolSize = zrUtil.isFunction(symbolSize);
- var isFnSymbolRotate = zrUtil.isFunction(symbolRotate);
- if (isFnSymbol || isFnSymbolSize || isFnSymbolRotate) {
- var rawIdx = mpModel.getRawValue(idx);
- var dataParams = mpModel.getDataParams(idx);
- if (isFnSymbol) {
- symbol = symbol(rawIdx, dataParams);
- }
- if (isFnSymbolSize) {
-
- symbolSize = symbolSize(rawIdx, dataParams);
- }
- if (isFnSymbolRotate) {
- symbolRotate = symbolRotate(rawIdx, dataParams);
- }
- }
- mpData.setItemVisual(idx, {
- symbol: symbol,
- symbolSize: symbolSize,
- symbolRotate: symbolRotate,
- color: itemModel.get('itemStyle.color') || seriesData.getVisual('color')
- });
- });
- symbolDraw.updateData(mpData);
- this.group.add(symbolDraw.group);
-
- mpData.eachItemGraphicEl(function (el) {
- el.traverse(function (child) {
- child.dataModel = mpModel;
- });
- });
- symbolDraw.__keep = true;
- symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
- }
- });
|