Chart improvements

Minor fixes  + refresh on supplier spend chart
This commit is contained in:
Tom Slater 2019-08-22 16:59:51 +01:00
parent 4130b2fb7d
commit 249c7ba93b
12 changed files with 118 additions and 81 deletions

13
package-lock.json generated
View file

@ -1153,6 +1153,14 @@
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
"dev": true "dev": true
}, },
"angular2-datetimepicker": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/angular2-datetimepicker/-/angular2-datetimepicker-1.1.1.tgz",
"integrity": "sha1-acTZkcSKYNq4CiDYfoU5bBhfH0I=",
"requires": {
"font-awesome": "*"
}
},
"ansi-colors": { "ansi-colors": {
"version": "3.2.4", "version": "3.2.4",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz",
@ -4016,6 +4024,11 @@
} }
} }
}, },
"font-awesome": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz",
"integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM="
},
"for-in": { "for-in": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",

View file

@ -33,6 +33,7 @@
"@coreui/icons": "0.3.0", "@coreui/icons": "0.3.0",
"ajv": "^6.10.0", "ajv": "^6.10.0",
"ajv-keywords": "^3.4.0", "ajv-keywords": "^3.4.0",
"angular2-datetimepicker": "^1.1.1",
"chart.js": "^2.8.0", "chart.js": "^2.8.0",
"chartjs-adapter-luxon": "^0.2.0", "chartjs-adapter-luxon": "^0.2.0",
"core-js": "^2.6.9", "core-js": "^2.6.9",

View file

@ -41,7 +41,6 @@ import { P500Component } from './pages/500.component';
// Submodules // Submodules
import { AuthModule } from './auth/auth.module'; import { AuthModule } from './auth/auth.module';
import { DashboardModule } from './dashboard/dashboard.module'; import { DashboardModule } from './dashboard/dashboard.module';
import { ChartsModule } from 'ng2-charts'; import { ChartsModule } from 'ng2-charts';
// import { StackedBarChartComponent } from './panels/stacked-bar.component'; // import { StackedBarChartComponent } from './panels/stacked-bar.component';
import { MoreStuffComponent } from './dashboard/more-graphs-and-tables.component'; import { MoreStuffComponent } from './dashboard/more-graphs-and-tables.component';

View file

@ -24,6 +24,7 @@
<span class="help-block">Enter the amount spent, such as 5.35 for £5.35.</span> <span class="help-block">Enter the amount spent, such as 5.35 for £5.35.</span>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label class="col-md-3 form-control-label" for="text-input">Essential Purchase</label> <label class="col-md-3 form-control-label" for="text-input">Essential Purchase</label>
<div class="col-md-9"> <div class="col-md-9">

View file

@ -42,17 +42,17 @@ export class DashboardCustomerComponent implements OnInit {
public doughnutChartColoursCategory: any[] = [ public doughnutChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor:[
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'red', '#ea1515',
'#000000' '#2d4fcc'
] ]
}]; }];
@ -121,17 +121,17 @@ export class DashboardCustomerComponent implements OnInit {
public barChartColoursCategory: any[] = [ public barChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor:[
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'red', '#ea1515',
'#000000' '#2d4fcc'
] ]
}]; }];

View file

@ -68,6 +68,7 @@
[datasets]="doughnutChartDataCategory" [datasets]="doughnutChartDataCategory"
[labels]="doughnutChartLabelsCategory" [labels]="doughnutChartLabelsCategory"
[options]="doughnutChartOptionsCategory" [options]="doughnutChartOptionsCategory"
[colors]="doughnutChartColoursCategory"
[legend]="chartLegend" [legend]="chartLegend"
[chartType]="chartType" [chartType]="chartType"
(chartHover)="chartHovered($event)" (chartHover)="chartHovered($event)"

View file

@ -84,16 +84,16 @@ export class DashboardComponent {
{ {
backgroundColor:[ backgroundColor:[
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'red', '#ea1515',
'#000000' '#2d4fcc'
] ]
}]; }];
@ -138,17 +138,17 @@ export class DashboardComponent {
public barChartColoursCategory: any[] = [ public barChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor:[
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'red', '#ea1515',
'#000000' '#2d4fcc'
] ]
}]; }];

View file

@ -30,6 +30,10 @@
<div class="col-sm-8"> <div class="col-sm-8">
<h4 class="card-title mb-0">Spend amount and number of organisations</h4> <h4 class="card-title mb-0">Spend amount and number of organisations</h4>
</div> </div>
<div class="col-sm-4 hidden-sm-down">
<input type="date" [(ngModel)]="lineChartBegin" (change)="lineChartUpdate()">
<input type="date" [(ngModel)]="lineChartEnd" (change)="lineChartUpdate()">
</div>
</div> </div>
<div> <div>
<canvas baseChart <canvas baseChart
@ -45,9 +49,12 @@
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
<div class="col-sm-5"> <div class="col-sm-8">
<h4 class="card-title mb-0">Supplier Spend History</h4> <h4 class="card-title mb-0">Supplier Spend History</h4>
</div> </div>
<div class="col-sm-4 hidden-sm-down">
<button (click)="supplierChartUpdate()">New Suppliers</button>
</div>
</div> </div>
<div> <div>
<canvas baseChart #supplierChart <canvas baseChart #supplierChart

View file

@ -82,7 +82,7 @@ export class MoreStuffComponent implements OnInit {
if (is_item_in_range) { if (is_item_in_range) {
graph_data.push({ graph_data.push({
t: new Date(item.date.substring(0, 10)), t: new Date(item.date.substring(0, 10)),
r: item.value > 1000000 ? (item.value / 100000) : (item.value / 100000) + 5, r: item.value > 1000000 ? (item.value / 200000) : (item.value / 100000) + 5,
supplier: item.seller, supplier: item.seller,
y: item.count, y: item.count,
value: item.value, value: item.value,
@ -151,8 +151,7 @@ export class MoreStuffComponent implements OnInit {
data: [], data: [],
label: ["Spend"], label: ["Spend"],
borderColor: 'blue', borderColor: 'blue',
hoverBackgroundColor: 'blue', hoverBorderColor: 'black',
hoverBorderColor: 'blue',
radius: 5, radius: 5,
}, },
]; ];
@ -287,13 +286,7 @@ export class MoreStuffComponent implements OnInit {
} }
lineChartUpdate() { lineChartUpdate() {
console.log("start_range input box: " + this.lineChartBegin.date); this.loadYearSpend(true, (this.lineChartBegin), (this.lineChartEnd));
console.log("start_range : " + new Date(this.lineChartBegin));
console.log("end_range input box: " + this.lineChartEnd);
console.log("end_range : " + new Date(this.lineChartEnd));
this.loadYearSpend();
console.log("Line chart updating...");
} }
@ -319,6 +312,26 @@ export class MoreStuffComponent implements OnInit {
} }
) )
} }
supplierChartUpdate() {
this.api.loadMiscUrl('organisation/external/supplier_history').subscribe(
result => {
let labels = [];
let year = [];
let half = [];
let quarter = [];
result.data.map(item => {
labels.push(item.name);
year.push(item.year_total);
half.push(item.half_total);
quarter.push(item.quarter_total);
});
this.supplierMonthChartData[0].data = quarter.slice(0,15);
this.supplierMonthChartData[1].data = half.slice(0,15);
this.supplierMonthChartData[2].data = year.slice(0,15);
this.supplierMonthChartLabels = labels.slice(0,15);
}
)
}
public supplierMonthChartData: any[] = [ public supplierMonthChartData: any[] = [
{ {
data: [], data: [],

View file

@ -49,11 +49,11 @@
</ul> </ul>
</pagination-template> </pagination-template>
<select (change)="loadSuppliers(1)" [(ngModel)]="perPage"> <select (change)="loadSuppliers(1)" [(ngModel)]="perPage">
<option>10</option> <option value="10">10</option>
<option>20</option> <option value="20">20</option>
<option>50</option> <option value="50">50</option>
<option>100</option> <option value="100">100</option>
<option>200</option> <option value="200">200</option>
</select> </select>
</div> </div>
<div *ngIf="!supplierListAvailable" class="card-block"> <div *ngIf="!supplierListAvailable" class="card-block">

View file

@ -17,18 +17,19 @@ export class OrgPiePanel implements OnInit {
public doughnutChartDataLocal: number[] = []; public doughnutChartDataLocal: number[] = [];
public doughnutChartColors: any[] = [ public doughnutChartColors: any[] = [
{ {
backgroundColor: [ backgroundColor:[
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'pink' '#ea1515',
] '#2d4fcc'
]
}, },
{ {
borderColor: [ borderColor: [

View file

@ -18,16 +18,17 @@ export class PiePanel implements OnInit {
public doughnutChartLabelsLocal: string[] = []; public doughnutChartLabelsLocal: string[] = [];
public doughnutChartColors: any[] = [ public doughnutChartColors: any[] = [
{ backgroundColor: [ { backgroundColor: [
'#ffa1b5', '#ffa1b5',
'green', '#3cde52',
'#52afed', '#52afed',
'purple', '#c133e3',
'yellow', '#f7fa08',
'brown', '#75152d',
'magenta', '#ee12ee',
'cyan', '#15eaea',
'orange', '#eaa015',
'pink', '#ea1515',
'#2d4fcc'
] ]
}, },
{ borderColor:[ { borderColor:[