@covalent/echarts
Version:
Teradata Charts built on echarts
183 lines (176 loc) • 6.04 kB
JavaScript
import { CommonModule } from '@angular/common';
import 'echarts/lib/component/toolbox';
import { Component, Input, Directive, TemplateRef, ChangeDetectionStrategy, ElementRef, ChangeDetectorRef, ContentChild, ViewChild, NgModule } from '@angular/core';
import { TdChartOptionsService, assignDefined } from '@covalent/echarts/base';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
class TdChartViewDataFormatterDirective {
}
TdChartViewDataFormatterDirective.decorators = [
{ type: Directive, args: [{
selector: 'ng-template[tdViewDataFormatter]',
},] }
];
class TdChartToolboxComponent {
/**
* @param {?} _changeDetectorRef
* @param {?} _elementRef
* @param {?} _optionsService
*/
constructor(_changeDetectorRef, _elementRef, _optionsService) {
this._changeDetectorRef = _changeDetectorRef;
this._elementRef = _elementRef;
this._optionsService = _optionsService;
this._state = {};
this.config = {};
this.show = true;
this.showTitle = true;
this.transitionDuration = 0.5;
this.left = 'auto';
this.top = 'auto';
this.right = 'auto';
this.bottom = 'auto';
this.width = 'auto';
this.height = 'auto';
}
/**
* @return {?}
*/
ngOnChanges() {
this._setOptions();
}
/**
* @return {?}
*/
ngOnDestroy() {
this._removeOption();
}
/**
* @return {?}
*/
_setOptions() {
this._checkFormatterTemplate();
/** @type {?} */
let config = assignDefined(this._state, {
show: this.show,
name: this.trigger,
orient: this.orient,
itemSize: this.itemSize,
itemGap: this.itemGap,
showTitle: this.showTitle,
label: this.label,
feature: this.feature,
iconStyle: this.iconStyle,
zlevel: this.zlevel,
z: this.z,
transitionDuration: this.transitionDuration,
left: this.left,
top: this.top,
right: this.right,
bottom: this.bottom,
width: this.width,
height: this.height,
}, this.config ? this.config : {});
// set toolbox configuration in parent chart and render new configurations
this._optionsService.setOption('toolbox', config);
}
/**
* @return {?}
*/
_removeOption() {
this._optionsService.clearOption('toolbox');
}
/**
* @return {?}
*/
_checkFormatterTemplate() {
if (this.formatterTemplate) {
this.feature = Object.assign({}, this.feature, { dataView: Object.assign({}, this.feature.dataView, { optionToContent: this._optionToContentFormatter() }) });
}
}
/**
* @return {?}
*/
_optionToContentFormatter() {
return () => {
this._changeDetectorRef.markForCheck();
return ((/** @type {?} */ (this._elementRef.nativeElement))).innerHTML;
};
}
}
TdChartToolboxComponent.decorators = [
{ type: Component, args: [{
selector: 'td-chart-toolbox',
template: "<ng-template #toolboxContent\n [ngTemplateOutlet]=\"formatterTemplate\">\n</ng-template>",
changeDetection: ChangeDetectionStrategy.OnPush
}] }
];
/** @nocollapse */
TdChartToolboxComponent.ctorParameters = () => [
{ type: ChangeDetectorRef },
{ type: ElementRef },
{ type: TdChartOptionsService }
];
TdChartToolboxComponent.propDecorators = {
config: [{ type: Input, args: ['config',] }],
show: [{ type: Input, args: ['show',] }],
trigger: [{ type: Input, args: ['name',] }],
orient: [{ type: Input, args: ['orient',] }],
itemSize: [{ type: Input, args: ['itemSize',] }],
itemGap: [{ type: Input, args: ['itemGap',] }],
showTitle: [{ type: Input, args: ['showTitle',] }],
label: [{ type: Input, args: ['label',] }],
feature: [{ type: Input, args: ['feature',] }],
iconStyle: [{ type: Input, args: ['iconStyle',] }],
zlevel: [{ type: Input, args: ['zlevel',] }],
z: [{ type: Input, args: ['z',] }],
transitionDuration: [{ type: Input, args: ['transitionDuration',] }],
left: [{ type: Input, args: ['left',] }],
top: [{ type: Input, args: ['top',] }],
right: [{ type: Input, args: ['right',] }],
bottom: [{ type: Input, args: ['bottom',] }],
width: [{ type: Input, args: ['width',] }],
height: [{ type: Input, args: ['height',] }],
formatterTemplate: [{ type: ContentChild, args: [TdChartViewDataFormatterDirective, { read: TemplateRef },] }],
fullTemplate: [{ type: ViewChild, args: ['toolboxContent',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/** @type {?} */
const TOOLBOX_MODULE_COMPONENTS = [
TdChartToolboxComponent,
TdChartViewDataFormatterDirective,
];
class CovalentToolboxEchartsModule {
}
CovalentToolboxEchartsModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
],
declarations: [
TOOLBOX_MODULE_COMPONENTS,
],
exports: [
TOOLBOX_MODULE_COMPONENTS,
],
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingReturn,uselessCode} checked by tsc
*/
export { TOOLBOX_MODULE_COMPONENTS, CovalentToolboxEchartsModule, TdChartViewDataFormatterDirective, TdChartToolboxComponent };
//# sourceMappingURL=covalent-echarts-toolbox.js.map