私はangular2 ng2-chart
を使い始めました。私はangular2 NG2-チャートを使用して作成し、以下の画像に関するいくつかの質問を持っているが、まだ多くのカスタマイズを行いたい:Angular2 ng2-chartのカスタマイズはありますか?
質問:私は間の点線を描くことができますどのように
1)上の画像のような値がないときの2つの点Nov-7は値0(ゼロ)ですか?
2)シャドウ効果、不透明度、または複数の色の組み合わせを作成するにはどうすればよいですか?
3)定義されたポイントのどれかにカーソルを置くと、マウスのホバーでy軸のグリッドの色を変更したい場合、y軸の値を取得するにはどうすればよいですか? ng2-chart hover関数を使用してそれを行う最良の方法は何ですか?
現在のサンプルコードや設定ファイル:
index.htmlを
<div class="container">
<div class="row">
<div class="overview-page">
<div class="overview-page-title">
<h2>Overview</h2>
</div>
<div class="chart-view">
<canvas baseChart
class="chart"
[datasets]="charts.datasets"
[labels]="charts.labels"
[colors]="charts.chartColors"
[options]="charts.options"
[legend]="false"
[chartType]="charts.type"
(chartHover)="chartHovered($event)">
</canvas>
</div>
</div>
</div>
</div>
index.component.ts
import {Component, Output, EventEmitter, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {Config} from '../../../config/config';
@Component({
templateUrl: 'index.html',
styleUrls: ['../../../../common/stylesheets/pages/index.scss']
})
export class IndexComponent implements OnInit {
protected charts: any;
ngOnInit() {
this.charts = (<any>Config.get('test')).charts;
console.log(this.charts);
}
chartHovered(e:any):void {
console.log(e);
}
}
Config.ts:
import * as Immutable from 'immutable';
export const Config = Immutable.Map({
test: {
charts: {
datasets: [{
data: [40, 48.2, 0, 52.6, 51.1, 57.6, 74.8]
}],
labels: ['Nov 5', 'Nov 6', 'Nov 7', 'Nov 8', 'Nov 9', 'Nov 10', 'Nov 11'],
type: 'line',
options: {
scales: {
xAxes: [{
gridLines: {
color: 'rgba(171,171,171,1)',
lineWidth: 1
}
}],
yAxes: [{
ticks: {
beginAtZero: true,
max: 100,
min: 0,
stepSize: 25
},
gridLines: {
color: 'rgba(171,171,171,1)',
lineWidth: 0.5
}
}]
},
responsive: true
},
chartColors: [{
backgroundColor: 'rgba(25,10,24,0.2)',
borderColor: 'rgba(225,10,24,0.2)',
pointBackgroundColor: 'rgba(225,10,24,0.2)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(225,10,24,0.2)'
}]
}
}
});
申し訳ありませんが、これは動作していません。私は高水準のライブラリとしてng2-chartsでは不可能だと考えました。 D3.jsまたはnvD3.jsで可能になるのは、コンポーネントに多くの制御を与えるためです。おかげさまで –