Icard/angular-clarity-master(work.../node_modules/highcharts/es-modules/Series/DrawPointUtilities.js

82 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
/* *
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
'use strict';
/* *
*
* Functions
*
* */
/**
* Handles the drawing of a component.
* Can be used for any type of component that reserves the graphic property,
* and provides a shouldDraw on its context.
*
* @private
*
* @todo add type checking.
* @todo export this function to enable usage
*/
function draw(point, params) {
const { animatableAttribs, onComplete, css, renderer } = params;
const animation = (point.series && point.series.chart.hasRendered) ?
// Chart-level animation on updates
void 0 :
// Series-level animation on new points
(point.series &&
point.series.options.animation);
let graphic = point.graphic;
params.attribs = {
...params.attribs,
'class': point.getClassName()
} || {};
if ((point.shouldDraw())) {
if (!graphic) {
if (params.shapeType === 'text') {
graphic = renderer.text();
}
else if (params.shapeType === 'image') {
graphic = renderer.image(params.imageUrl || '')
.attr(params.shapeArgs || {});
}
else {
graphic = renderer[params.shapeType](params.shapeArgs || {});
}
point.graphic = graphic;
graphic.add(params.group);
}
if (css) {
graphic.css(css);
}
graphic
.attr(params.attribs)
.animate(animatableAttribs, params.isNew ? false : animation, onComplete);
}
else if (graphic) {
const destroy = () => {
point.graphic = graphic = (graphic && graphic.destroy());
if (typeof onComplete === 'function') {
onComplete();
}
};
// Animate only runs complete callback if something was animated.
if (Object.keys(animatableAttribs).length) {
graphic.animate(animatableAttribs, void 0, () => destroy());
}
else {
destroy();
}
}
}
/* *
*
* Default Export
*
* */
const DrawPointUtilities = {
draw
};
export default DrawPointUtilities;