1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 3657× 3657× 3657× 1× 3149× 3149× 3149× 3149× 24682× 23274× 24773× 24773× 3149× 24682× 24682× 1× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 24971× 18980× 18980× 24971× 24971× 24966× 24966× 3012× 21954× 225× 21729× 24966× 24966× 24966× 6931× 18035× 24966× 24966× 24966× 24966× 24966× 24966× 24966× 24966× 2390× 2390× 2390× 2390× 24966× 24966× 24205× 24205× 24966× 24966× 267× 24966× 5× 5× 1× 3149× 3149× 3149× 3149× 3149× 3149× 3149× 3149× 3095× 3095× 3095× 2953× 2953× 142× 142× 3095× 3095× 3095× 3095× 29× 29× 1× 1× 1549× 1549× 1549× 1× 403× 399× 399× 399× 399× 399× 399× 399× 1609× 1549× 1549× 399× 399× 399× 3467× 3467× 95× 3372× 1850× 283× 1850× 1567× 1567× 3372× 3372× 3372× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "../../common/utils/helper", "../../common/utils/helper", "@syncfusion/ej2-svg-base", "@syncfusion/ej2-base", "../../common/model/constants", "./marker-explode", "../../common/utils/helper"], function (require, exports, helper_1, helper_2, ej2_svg_base_1, ej2_base_1, constants_1, marker_explode_1, helper_3) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.markerShapes = ['Circle', 'Triangle', 'Diamond', 'Rectangle', 'Pentagon', 'InvertedTriangle', 'VerticalLine', 'Cross', 'Plus', 'HorizontalLine', 'Star']; var Marker = (function (_super) { __extends(Marker, _super); function Marker(chart) { var _this = _super.call(this, chart) || this; _this.addEventListener(); return _this; } Marker.prototype.render = function (series) { var _this = this; var redraw = series.chart.redraw; this.createElement(series, redraw); var _loop_1 = function (point) { if (point.visible && point.symbolLocations && point.symbolLocations.length) { point.symbolLocations.map(function (location, index) { Eif (series.marker.shape !== 'None') { _this.renderMarker(series, point, location, index, redraw); } }); } }; for (var _i = 0, _a = series.points; _i < _a.length; _i++) { var point = _a[_i]; _loop_1(point); } }; Marker.prototype.renderMarker = function (series, point, location, index, redraw) { var seriesIndex = series.index === undefined ? series.category : series.index; var marker = series.marker; series.marker.shape = series.marker.shape ? series.marker.shape : exports.markerShapes[seriesIndex % 10]; var border = { color: marker.border.color, width: marker.border.width }; var borderColor = marker.border.color; var previousLocation; var previousPath; var circlePath; var shapeOption; location.x = location.x + marker.offset.x; location.y = location.y - marker.offset.y; var isBoxPlot = series.type === 'BoxAndWhisker'; var fill = marker.fill || ((isBoxPlot || series.marker.isFilled) ? point.interior || series.interior : '#ffffff'); var markerElement; var parentElement = isBoxPlot && !this.chart.enableCanvas ? helper_2.findlElement(series.seriesElement.childNodes, 'Series_' + series.index + '_Point_' + point.index) : series.symbolElement; border.color = borderColor || series.setPointColor(point, series.interior); var symbolId = this.elementId + '_Series_' + seriesIndex + '_Point_' + ((series.removedPointIndex !== null && series.removedPointIndex <= point.index) || this.chart.pointsAdded ? (point.index + 1) : point.index) + '_Symbol' + (index ? index : ''); var argsData = { cancel: false, name: constants_1.pointRender, series: series, point: point, fill: point.isEmpty ? (series.emptyPointSettings.fill || fill) : fill, border: { color: series.type === 'BoxAndWhisker' ? (!ej2_base_1.isNullOrUndefined(borderColor) && borderColor !== 'transparent') ? borderColor : helper_3.getSaturationColor(fill, -0.6) : border.color, width: border.width }, height: marker.height, width: marker.width, shape: marker.shape }; argsData.border = series.setBorderColor(point, { width: argsData.border.width, color: argsData.border.color }); if (!series.isRectSeries || series.type === 'BoxAndWhisker') { this.chart.trigger(constants_1.pointRender, argsData); point.color = argsData.fill; } point.color = argsData.fill; if (!argsData.cancel) { var y = void 0; if (series.type === 'RangeArea' || series.type === 'RangeColumn' || series.drawType === 'RangeColumn' || series.type === 'SplineRangeArea' || series.type === 'RangeStepArea') { y = index ? point.low : point.high; } else if (isBoxPlot) { y = point.outliers[index]; } else { y = point.y; } var markerFill = argsData.point.marker.fill || argsData.fill; var markerBorder = void 0; if (!ej2_base_1.isNullOrUndefined(argsData.point.marker.border)) { markerBorder = { color: argsData.point.marker.border.color || argsData.border.color, width: argsData.point.marker.border.width || argsData.border.width }; } else { markerBorder = { color: argsData.border.color, width: argsData.border.width }; } var markerWidth = argsData.point.marker.width || argsData.width; var markerHeight = argsData.point.marker.height || argsData.height; var markerOpacity = argsData.point.marker.opacity || marker.opacity; var markerShape = argsData.point.marker.shape || argsData.shape; var imageURL = argsData.point.marker.imageUrl || marker.imageUrl; shapeOption = new ej2_svg_base_1.PathOption(symbolId, markerFill, markerBorder.width, markerBorder.color, markerOpacity, series.marker.border.dashArray); Eif ((parentElement !== undefined && parentElement !== null) || this.chart.enableCanvas) { if (redraw && helper_1.getElement(shapeOption.id)) { markerElement = helper_1.getElement(shapeOption.id); circlePath = markerShape === 'Circle' ? 'c' : ''; previousLocation = { x: +markerElement.getAttribute(circlePath + 'x'), y: +markerElement.getAttribute(circlePath + 'y') }; previousPath = markerElement.getAttribute('d'); } markerElement = helper_2.drawSymbol(location, markerShape, new ej2_svg_base_1.Size(markerWidth, markerHeight), imageURL, shapeOption, point.x.toString() + ':' + y.toString(), this.chart.renderer, series.clipRect); if (markerElement) { markerElement.setAttribute('role', 'img'); markerElement.setAttribute('aria-label', (point.x + ': ' + point.y + ', ' + series.name)); } helper_1.appendChildElement(this.chart.enableCanvas, parentElement, markerElement, redraw, true, circlePath + 'x', circlePath + 'y', previousLocation, previousPath, false, false, null, series.chart.duration); if ((series.removedPointIndex !== null && series.removedPointIndex <= point.index)) { parentElement.lastChild.id = this.elementId + '_Series_' + seriesIndex + '_Point_' + point.index + '_Symbol' + (index ? index : ''); } } point.marker = { border: markerBorder, fill: markerFill, height: markerHeight, visible: true, shape: markerShape, width: markerWidth, imageUrl: imageURL }; } else { location = null; point.marker = { visible: false }; } }; Marker.prototype.createElement = function (series, redraw) { var markerClipRect; var marker = series.marker; var explodeValue = marker.border.width + 8 + 5; var render = series.chart.svgRenderer; var index = series.index === undefined ? series.category : series.index; var options; var transform = series.chart.chartAreaType === 'Cartesian' ? 'translate(' + series.clipRect.x + ',' + (series.clipRect.y) + ')' : ''; if (marker.visible) { var markerHeight = (marker.height + explodeValue) / 2; var markerWidth = (marker.width + explodeValue) / 2; if (series.chart.chartAreaType === 'Cartesian') { options = new helper_1.RectOption(this.elementId + '_ChartMarkerClipRect_' + index, 'transparent', { width: 1, color: 'Gray' }, 1, { x: -markerWidth, y: -markerHeight, width: series.clipRect.width + (markerWidth * 2), height: series.clipRect.height + markerHeight * 2 }, 0, 0, '', series.marker.border.dashArray); markerClipRect = helper_1.appendClipElement(redraw, options, render); } else { options = new helper_2.CircleOption(this.elementId + '_ChartMarkerClipRect_' + index, 'transparent', { width: 1, color: 'Gray' }, 1, series.clipRect.width / 2 + series.clipRect.x, series.clipRect.height / 2 + series.clipRect.y, series.chart.radius + Math.max(markerHeight, markerWidth)); markerClipRect = helper_1.appendClipElement(redraw, options, render, 'drawCircularClipPath'); } options = { 'id': this.elementId + 'SymbolGroup' + index, 'transform': transform, 'clip-path': 'url(#' + this.elementId + '_ChartMarkerClipRect_' + index + ')' }; series.symbolElement = render.createGroup(options); series.symbolElement.appendChild(markerClipRect); if (this.chart.enableCanvas) { var element = document.getElementById(this.chart.element.id + '_tooltip_svg'); element.appendChild(series.symbolElement); } } }; Marker.prototype.getRangeLowPoint = function (region, series) { var x = region.x; var y = region.y; if (series.chart.requireInvertedAxis) { y += region.height / 2; x += series.yAxis.isAxisInverse ? region.width : 0; } else { y += series.yAxis.isAxisInverse ? 0 : region.height; x += region.width / 2; } return { x: x, y: y }; }; Marker.prototype.calculateDistance = function (startPoint, endPoint) { var dx = endPoint.x - startPoint.x; var dy = endPoint.y - startPoint.y; return Math.sqrt(dx * dx + dy * dy); }; Marker.prototype.doMarkerAnimation = function (series) { if (!(series.type === 'Scatter' || series.type === 'Bubble' || series.type === 'Candle' || series.type === 'Hilo' || series.type === 'HiloOpenClose' || (series.chart.chartAreaType === 'PolarRadar' && (series.drawType === 'Scatter')))) { var markerElements = series.symbolElement.childNodes; var delay = series.animation.delay + (series.animation.duration === 0 && ej2_base_1.animationMode === 'Enable' ? 1000 : series.animation.duration); var duration = series.chart.animated ? series.chart.duration : 200; var markerDelay = delay; var pathLength = series.pathElement ? series.pathElement.getTotalLength() : 0; var distances = []; for (var i = 1; (series.type === 'Line' && i < series.points.length); i++) { if (series.points[i - 1].symbolLocations[0] && series.points[i].symbolLocations[0]) { var distance = this.calculateDistance(series.points[i - 1].symbolLocations[0], series.points[i].symbolLocations[0]); distances.push(distance); } } var j = 1; var incFactor = (series.type === 'RangeArea' || series.type === 'RangeColumn' || series.type === 'SplineRangeArea' || series.type === 'RangeStepArea') ? 2 : 1; for (var i = 0; i < series.points.length; i++) { Eif (series.points[i].symbolLocations) { if (!series.points[i].symbolLocations.length || !markerElements[j]) { continue; } if (series.type === 'Line') { if (i === 0) { markerDelay = 0; } if (i > 0) { markerDelay += (distances[i - 1] / pathLength) * delay; duration = 0; } } helper_2.markerAnimate(markerElements[j], markerDelay, duration, series, i, series.points[i].symbolLocations[0], false); Iif (incFactor === 2) { var lowPoint = this.getRangeLowPoint(series.points[i].regions[0], series); helper_2.markerAnimate(markerElements[j + 1], markerDelay, duration, series, i, lowPoint, false); } j += incFactor; } } } }; return Marker; }(marker_explode_1.MarkerExplode)); exports.Marker = Marker; }); |