代码之家  ›  专栏  ›  技术社区  ›  Chris

如何扩展组件

  •  0
  • Chris  · 技术社区  · 6 年前

    我用的是 charting library 它要么没有我期望的那样工作,要么有一个bug(或者两者兼而有之…),我很好奇我是否可以简单地通过重写绑定或其他东西来禁用某些功能。我不确定这到底是一个角度问题还是javascript问题。

    例如,在下面的定义中,我对(activate)和(deactivate)的工作方式不满意。

           <svg:g
              *ngFor="let group of results; let index = index; trackBy:trackBy"
              [@animationState]="'active'"
              [attr.transform]="groupTransform(group)">
              <svg:g ngx-charts-series-vertical
                type="stacked"
                [xScale]="xScale"
                [yScale]="yScale"
                [activeEntries]="activeEntries"
                [colors]="colors"
                [series]="group.series"
                [dims]="dims"
                [gradient]="gradient"
                [tooltipDisabled]="tooltipDisabled"
                [tooltipTemplate]="tooltipTemplate"
                [showDataLabel]="showDataLabel"
                [dataLabelFormatting]="dataLabelFormatting"
                [seriesName]="group.name"
                [animations]="animations"
                (select)="onClick($event, group)"
                (activate)="onActivate($event, group)"
                (deactivate)="onDeactivate($event, group)"
                (dataLabelHeightChanged)="onDataLabelMaxHeightChanged($event, index)"
              />
    

    如果在我的应用程序声明中包含该组件,即使在任何地方都没有引用它,也会发生这种情况。

    import { Component } from '@angular/core';
    import { StackedBarViewComponent } from './stackedbarview.component';
    import { BarVerticalStackedComponent } from '@swimlane/ngx-charts';
    
    @Component({
      selector: 'verticalstackedbarchartca',
      templateUrl: './verticalstackedbarchartca.component.html',
      styleUrls: ['./verticalstackedbarchartca.component.css']
    })
    
    export class VerticalStackedBarChartCustomActivenessComponent extends BarVerticalStackedComponent {
    
    
      onActivate(event, group?) {
        console.log('custom onActivate(' + event + "," + group + ")");
      }
    
      onDeactivate(event, group?) {
        console.log('custom onDeactivate(' + event + "," + group + ")");
      }
    }
    

    0 回复  |  直到 6 年前