ng-apexcharts
Version:
An angular implementation of ApexCharts
366 lines (355 loc) • 12.4 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs')) :
typeof define === 'function' && define.amd ? define('ng-apexcharts', ['exports', '@angular/core', 'rxjs'], factory) :
(factory((global['ng-apexcharts'] = {}),global.ng.core,global.rxjs));
}(this, (function (exports,core,rxjs) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ChartComponent = /** @class */ (function () {
function ChartComponent() {
this.dataLabels = { enabled: false };
this.stroke = { curve: 'straight' };
this.grid = {
row: {
colors: ['#f3f3f3', 'transparent'],
opacity: 0.5
}
};
this.autoUpdateSeries = true;
}
/**
* @return {?}
*/
ChartComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
rxjs.asapScheduler.schedule(( /**
* @return {?}
*/function () {
_this.createElement();
}));
};
/**
* @param {?} changes
* @return {?}
*/
ChartComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
rxjs.asapScheduler.schedule(( /**
* @return {?}
*/function () {
if (_this.autoUpdateSeries && Object.keys(changes).filter(( /**
* @param {?} c
* @return {?}
*/function (c) { return c !== 'series'; })).length === 0) {
_this.updateSeries(_this.series, true);
return;
}
_this.createElement();
}));
};
/**
* @private
* @return {?}
*/
ChartComponent.prototype.createElement = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var options = {};
if (this.annotations) {
options.annotations = this.annotations;
}
if (this.chart) {
options.chart = this.chart;
}
if (this.colors) {
options.colors = this.colors;
}
if (this.dataLabels) {
options.dataLabels = this.dataLabels;
}
if (this.series) {
options.series = this.series;
}
if (this.stroke) {
options.stroke = this.stroke;
}
if (this.labels) {
options.labels = this.labels;
}
if (this.legend) {
options.legend = this.legend;
}
if (this.fill) {
options.fill = this.fill;
}
if (this.tooltip) {
options.tooltip = this.tooltip;
}
if (this.plotOptions) {
options.plotOptions = this.plotOptions;
}
if (this.responsive) {
options.responsive = this.responsive;
}
if (this.xaxis) {
options.xaxis = this.xaxis;
}
if (this.yaxis) {
options.yaxis = this.yaxis;
}
if (this.grid) {
options.grid = this.grid;
}
if (this.states) {
options.states = this.states;
}
if (this.title) {
options.title = this.title;
}
if (this.subtitle) {
options.subtitle = this.subtitle;
}
if (this.theme) {
options.theme = this.theme;
}
if (this.chartObj) {
this.chartObj.destroy();
}
this.chartObj = new ApexCharts(this.chartElement.nativeElement, options);
this.render();
};
/**
* @return {?}
*/
ChartComponent.prototype.render = /**
* @return {?}
*/
function () {
return this.chartObj.render();
};
/**
* @param {?} options
* @param {?} redrawPaths
* @param {?} animate
* @return {?}
*/
ChartComponent.prototype.updateOptions = /**
* @param {?} options
* @param {?} redrawPaths
* @param {?} animate
* @return {?}
*/
function (options, redrawPaths, animate) {
return this.chartObj.updateOptions(options, redrawPaths, animate);
};
/**
* @param {?} newSeries
* @param {?} animate
* @return {?}
*/
ChartComponent.prototype.updateSeries = /**
* @param {?} newSeries
* @param {?} animate
* @return {?}
*/
function (newSeries, animate) {
this.chartObj.updateSeries(newSeries, animate);
};
/**
* @param {?} seriesName
* @return {?}
*/
ChartComponent.prototype.toggleSeries = /**
* @param {?} seriesName
* @return {?}
*/
function (seriesName) {
this.chartObj.toggleSeries(seriesName);
};
/**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
ChartComponent.prototype.addXaxisAnnotation = /**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
function (options, pushToMemory, context) {
this.chartObj.addXaxisAnnotation(options, pushToMemory, context);
};
/**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
ChartComponent.prototype.addYaxisAnnotation = /**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
function (options, pushToMemory, context) {
this.chartObj.addYaxisAnnotation(options, pushToMemory, context);
};
/**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
ChartComponent.prototype.addPointAnnotation = /**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
function (options, pushToMemory, context) {
this.chartObj.addPointAnnotation(options, pushToMemory, context);
};
/**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
ChartComponent.prototype.addText = /**
* @param {?} options
* @param {?=} pushToMemory
* @param {?=} context
* @return {?}
*/
function (options, pushToMemory, context) {
this.chartObj.addText(options, pushToMemory, context);
};
/**
* @return {?}
*/
ChartComponent.prototype.dataURI = /**
* @return {?}
*/
function () {
return this.chartObj.dataURI();
};
ChartComponent.decorators = [
{ type: core.Component, args: [{
selector: 'apx-chart',
template: "<div #chart></div>\n",
styles: [""]
}] }
];
ChartComponent.propDecorators = {
chart: [{ type: core.Input }],
annotations: [{ type: core.Input }],
colors: [{ type: core.Input }],
dataLabels: [{ type: core.Input }],
series: [{ type: core.Input }],
stroke: [{ type: core.Input }],
labels: [{ type: core.Input }],
legend: [{ type: core.Input }],
fill: [{ type: core.Input }],
tooltip: [{ type: core.Input }],
plotOptions: [{ type: core.Input }],
responsive: [{ type: core.Input }],
xaxis: [{ type: core.Input }],
yaxis: [{ type: core.Input }],
grid: [{ type: core.Input }],
states: [{ type: core.Input }],
title: [{ type: core.Input }],
subtitle: [{ type: core.Input }],
theme: [{ type: core.Input }],
autoUpdateSeries: [{ type: core.Input }],
chartElement: [{ type: core.ViewChild, args: ['chart',] }]
};
return ChartComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var declerations = [
ChartComponent
];
var NgApexchartsModule = /** @class */ (function () {
function NgApexchartsModule() {
}
NgApexchartsModule.decorators = [
{ type: core.NgModule, args: [{
declarations: __spread(declerations),
imports: [],
exports: __spread(declerations)
},] }
];
return NgApexchartsModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
exports.NgApexchartsModule = NgApexchartsModule;
exports.ChartComponent = ChartComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ng-apexcharts.umd.js.map