1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
import { Component, OnInit, Injectable, ViewChild, ChangeDetectorRef } from '@angular/core';
import { RestApiService } from '../../shared/rest-api.service';
import * as Chartist from 'chartist';
import { ChartType, ChartEvent } from 'ng-chartist';
...
...
export interface Chart {
type: ChartType;
data: Chartist.IChartistData;
options?: any;
responsiveOptions?: any;
events?: ChartEvent;
}
...
...
ProjectZeroMonthAgo = 0;
ProjectOneMonthAgo = 0;
...
...
@ViewChild('visitor-chart') chart2: ChartComponent = Object.create(null);
public VisitorChartOptions: Partial<VisitorChartOptions>;
@ViewChild('newsletter-chart') chart3: ChartComponent = Object.create(null);
public newsletterchartOptions: Partial<newsletterchartOptions>;
ngOnInit() {
this.getNamespaces();
}
getNamespaces(){
this.dataService.getAllNameSpaces().subscribe((res)=>{
this.datamoi = res;
this.Traitement();
});
}
Traitement(){
var ZeroMonthAgo = convertDate(new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()));
...
...
console.log("Ma data est dans plusieurs variables, dont celle-ci " + this.ProjectZeroMonthAgo )
}
constructor(private dataService: RestApiService) {
this.VisitorChartOptions = {
series: [45, 15, 27, 18],
chart: {
type: 'donut',
height: 290
},
plotOptions: {
pie: {
donut: {
size: '80px'
}
}
},
tooltip: {
fillSeriesColor: false,
},
dataLabels: {
enabled: false,
},
stroke: {
width: 0
},
legend: {
show: false,
},
labels: ['Mobile', 'Tablet', 'Desktop', 'Other'],
colors: ['#1e88e5', '#26c6da', '#745af2', '#eceff1'],
responsive: [
{
breakpoint: 480,
options: {
chart: {
width: 200
}
}
}
]
};
this.newsletterchartOptions = {
series: [
{
name: 'Clicked',
data: [this.ProjectZeroMonthAgo, this.ProjectOneMonthAgo, 15000, 1000, 1500, 9000, 3000, 0, 5000, 15000, 8000, 1500, 9000, 3000, 0] // Mes variables ne prennent pas la data souhaitée, mais celle de l'initialisation.
},
{
name: 'Sent',
data: [100, 3000, 5000, 2000, 1600, 1000, 5000, 0, 3000, 5000, 2000, 8000, 1000, 5000, 0]
}
],
chart: {
height: 290,
type: 'area'
},
dataLabels: {
enabled: false
},
markers: {
size: 3,
},
stroke: {
curve: 'smooth',
width: '2'
},
colors: ['#26c6da', '#1e88e5'],
legend: {
show: false,
},
grid: {
borderColor: 'rgba(0,0,0,.2)',
strokeDashArray: 3,
yaxis: {
lines: {
show: true
}
},
xaxis: {
lines: {
show: true
}
},
},
xaxis: {
type: 'category',
categories: [
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020',
'01/2020'
]
},
tooltip: {
x: {
format: 'dd/MM/yy HH:mm'
}
}
};
}
} |