2016-11-10 55 views
1

我在Angular 2上測試了不同的圖表庫,所以我在不同的圖表庫上編寫了serval指令,比如D3,Flot,uvChart等。 我做了一個C3圖表之後,我有一個奇怪的圖從C3 this is the imageAngular2 C3圖表顏色很奇怪

你可以看到線之間的顏色反轉爲黑色,當我將鼠標懸停它的提示顏色被逆轉,以白色

下面是我的一些代碼的一部分

c3.directive.ts:

import { Directive, ElementRef, Renderer, Input } from '@angular/core'; 
declare var jQuery: any; 
declare var c3: any; 

@Directive({ 
    selector: '[c3-chart]' 
}) 

export class C3ChartDirective { 
    $el: any; 
    @Input() data: any; 
    @Input() options: string; 

    constructor(el: ElementRef, renderer: Renderer) { 
    this.$el = jQuery(el.nativeElement); 
    } 

    ngOnInit(): void { 
    this.render(); 
    } 

    // c3 chart render function 
    render(): void { 
    let elementID = '#' + this.$el.attr('id'); 
    console.log(elementID); 

    let chart = c3.generate({ 
    bindto: elementID, 
    data: { 
     columns: [ 
     ['data1', 30, 200, 100, 400, 150, 250], 
     ['data2', 50, 20, 10, 40, 15, 25] 
     ] 
    } 
}); 
    } 
} 

c3.module.ts:

import { NgModule } from '@angular/core'; 
import { C3ChartDirective } from './index'; 

@NgModule({ 
    declarations: [ 
    C3ChartDirective 
    ], 
    exports: [ 
    C3ChartDirective 
    ] 
}) 

export class C3Module{ 

} 

回答

1

很好,它已經過了幾天,沒有人回答我的問題。我自己解決了它。問題在於圖表組件中,我必須包含styleUrls鏈接以對應每個圖表指令的.css文件。

+0

選擇你自己的答案與綠色問號正確的答案獲得一定點:) – jhhoff02

+1

得到它,感謝您的意見 –