@obliczeniowo/elementary
Version:
Library made in Angular version 20
129 lines (124 loc) • 7.36 kB
JavaScript
import * as i2 from '@obliczeniowo/elementary/simple-diagram2-d';
import { SimpleDiagram2DModule } from '@obliczeniowo/elementary/simple-diagram2-d';
import * as i0 from '@angular/core';
import { ContentChild, Input, Component, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Point2DData } from '@obliczeniowo/elementary/classes';
class StatisticDiagramComponent {
hovered;
touched = false;
/** header text to display */
header = '';
/** mixed point coordinates and data as string to display on hover with y value by default */
points = [];
/** width */
width = 250;
/** height */
height = 50;
/**
* disable the whole things
*/
disabled = false;
/**
* reference to detected in ng-content template with #hoveredRef used to replace default way of displaying statistic on
* mouse over
*
* @example
*
* <obl-statistic-diagram [points]="points">
* <ng-template let-hovered #hoveredRef>
* {{ hovered.original.extData }} Value:
* {{ hovered.original.y }}
* </ng-template>
* </obl-statistic-diagram>
*/
hoveredRef;
onChange = (value) => { };
onTouched = () => { };
registerOnValidatorChange(fn) { this.onChange = fn; }
writeValue(set) {
console.log(set);
this.points = set.map(pt => new Point2DData(pt.x, pt.y, pt.extData));
}
registerOnChange(onChange) {
this.onChange = onChange;
}
registerOnTouched(onTouched) {
this.onTouched = onTouched;
}
setDisabledState(disabled) {
this.disabled = disabled;
}
markAsTouched() {
if (this.disabled) {
return;
}
if (!this.touched) {
this.onTouched();
this.touched = true;
}
}
setHovered(point) {
this.hovered = point;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.4", type: StatisticDiagramComponent, isStandalone: false, selector: "obl-statistic-diagram", inputs: { header: "header", points: "points", width: "width", height: "height", disabled: "disabled" }, providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: StatisticDiagramComponent
},
], queries: [{ propertyName: "hoveredRef", first: true, predicate: ["hoveredRef"], descendants: true }], ngImport: i0, template: "<h3>\n @if (!hovered) {\n {{ header }}\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n hoveredRef || defaultHoveredRef;\n context: { $implicit: hovered }\n \"\n >\n </ng-container>\n }\n</h3>\n\n<obl-simple-diagram2-d\n [points]=\"points\"\n [padding]=\"5\"\n [style.width.px]=\"width\"\n [style.height.px]=\"height\"\n [width]=\"width\"\n [height]=\"height\"\n [interactive]=\"true\"\n (hover)=\"setHovered($event)\"\n #diagram\n>\n @if (hovered) {\n <svg:circle\n [attr.cx]=\"hovered.converted.x\"\n [attr.cy]=\"hovered.converted.y\"\n r=\"5\"\n ></svg:circle>\n }\n</obl-simple-diagram2-d>\n\n<ng-template let-hovered #defaultHoveredRef>\n {{ hovered.original.extData + ': ' + hovered.original.y }}\n</ng-template>", styles: ["h3{margin:0;font-size:12px;font-weight:400;padding:0 5px}circle{fill:var(--obl-primary)}\n"], dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i2.SimpleDiagram2DComponent, selector: "obl-simple-diagram2-d", inputs: ["points", "gradient", "gradientUnits", "padding", "diagramBottomPadding", "height", "width", "interactive"], outputs: ["recalculate", "hover"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramComponent, decorators: [{
type: Component,
args: [{ selector: 'obl-statistic-diagram', providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: StatisticDiagramComponent
},
], standalone: false, template: "<h3>\n @if (!hovered) {\n {{ header }}\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n hoveredRef || defaultHoveredRef;\n context: { $implicit: hovered }\n \"\n >\n </ng-container>\n }\n</h3>\n\n<obl-simple-diagram2-d\n [points]=\"points\"\n [padding]=\"5\"\n [style.width.px]=\"width\"\n [style.height.px]=\"height\"\n [width]=\"width\"\n [height]=\"height\"\n [interactive]=\"true\"\n (hover)=\"setHovered($event)\"\n #diagram\n>\n @if (hovered) {\n <svg:circle\n [attr.cx]=\"hovered.converted.x\"\n [attr.cy]=\"hovered.converted.y\"\n r=\"5\"\n ></svg:circle>\n }\n</obl-simple-diagram2-d>\n\n<ng-template let-hovered #defaultHoveredRef>\n {{ hovered.original.extData + ': ' + hovered.original.y }}\n</ng-template>", styles: ["h3{margin:0;font-size:12px;font-weight:400;padding:0 5px}circle{fill:var(--obl-primary)}\n"] }]
}], propDecorators: { header: [{
type: Input
}], points: [{
type: Input
}], width: [{
type: Input
}], height: [{
type: Input
}], disabled: [{
type: Input
}], hoveredRef: [{
type: ContentChild,
args: ['hoveredRef']
}] } });
class StatisticDiagramModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramModule, declarations: [StatisticDiagramComponent], imports: [CommonModule,
SimpleDiagram2DModule], exports: [StatisticDiagramComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramModule, imports: [CommonModule,
SimpleDiagram2DModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: StatisticDiagramModule, decorators: [{
type: NgModule,
args: [{
declarations: [
StatisticDiagramComponent
],
imports: [
CommonModule,
SimpleDiagram2DModule
],
exports: [
StatisticDiagramComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { StatisticDiagramComponent, StatisticDiagramModule };
//# sourceMappingURL=obliczeniowo-elementary-statistic-diagram.mjs.map