Skip to content

Commit

Permalink
Merge pull request #1 from denStrigo/ecommerce-dashboard-orders-profi…
Browse files Browse the repository at this point in the history
…t-card

 feat(ecommerce): add order chart, add profit chart template
  • Loading branch information
ESadouski authored Jun 27, 2018
2 parents d0a774a + 5357c63 commit 730fa9c
Show file tree
Hide file tree
Showing 14 changed files with 773 additions and 124 deletions.
46 changes: 46 additions & 0 deletions src/app/@theme/styles/theme.corporate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,51 @@ export const CORPORATE_THEME = {
axisLineColor: '#cccccc',
textColor: '#484848',
},

// TODO: need design for corporate theme
orders: {
tooltipBg: 'rgba(0, 255, 170, 0.35)',
tooltipLineColor: 'rgba(255, 255, 255, 0.1)',
tooltipLineWidth: '1',
tooltipBorderColor: '#00d977',
tooltipExtraCss: 'box-shadow: 0px 2px 46px 0 rgba(0, 255, 170, 0.35); border-radius: 10px; padding: 8px 24px;',
tooltipTextColor: '#ffffff',
tooltipFontWeight: 'normal',

axisLineColor: 'rgba(161, 161 ,229, 0.3)',
xAxisTextColor: '#a1a1e5',
yAxisSplitLine: 'rgba(161, 161 ,229, 0.2)',

itemBorderColor: '#ffffff',
lineStyle: 'solid',
lineWidth: '6',

// green line
greenLineGradFrom: '#00bece',
greenLineGradTo: '#00da78',
greenLineShadow: 'rgba(14, 16, 48, 0.4)',

greenAreaGradFrom: 'rgba(31 ,106, 124, 0.5)',
greenAreaGradTo: 'rgba(4, 126, 230, 0)',
greenShadowLineDarkBg: '#2c5a85',

// purple line
purpleLineGradFrom: '#8069ff',
purpleLineGradTo: '#8357ff',
purpleLineShadow: 'rgba(14, 16, 48, 0.4)',

purpleAreaGradFrom: 'rgba(188, 92, 255, 0.5)',
purpleAreaGradTo: 'rgba(188, 92, 255, 0)',
purpleShadowLineDarkBg: '#a695ff',

// blue line
blueLineGradFrom: '#3bb0ff',
blueLineGradTo: '#0089ff',
blueLineShadow: 'rgba(14, 16, 48, 0.4)',

blueAreaGradFrom: 'rgba(4, 126, 230, 1)',
blueAreaGradTo: 'rgba(4, 126, 230, 0)',
blueShadowLineDarkBg: '#018dff',
},
},
};
45 changes: 45 additions & 0 deletions src/app/@theme/styles/theme.cosmic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,50 @@ export const COSMIC_THEME = {
axisLineColor: '#a1a1e5',
textColor: '#ffffff',
},

orders: {
tooltipBg: 'rgba(0, 255, 170, 0.35)',
tooltipLineColor: 'rgba(255, 255, 255, 0.1)',
tooltipLineWidth: '1',
tooltipBorderColor: '#00d977',
tooltipExtraCss: 'box-shadow: 0px 2px 46px 0 rgba(0, 255, 170, 0.35); border-radius: 10px; padding: 8px 24px;',
tooltipTextColor: '#ffffff',
tooltipFontWeight: 'normal',

axisLineColor: 'rgba(161, 161 ,229, 0.3)',
xAxisTextColor: '#a1a1e5',
yAxisSplitLine: 'rgba(161, 161 ,229, 0.2)',

itemBorderColor: '#ffffff',
lineStyle: 'solid',
lineWidth: '6',

// green line
greenLineGradFrom: '#00bece',
greenLineGradTo: '#00da78',
greenLineShadow: 'rgba(14, 16, 48, 0.4)',

greenAreaGradFrom: 'rgba(31 ,106, 124, 0.5)',
greenAreaGradTo: 'rgba(4, 126, 230, 0)',
greenShadowLineDarkBg: '#2c5a85',

// purple line
purpleLineGradFrom: '#8069ff',
purpleLineGradTo: '#8357ff',
purpleLineShadow: 'rgba(14, 16, 48, 0.4)',

purpleAreaGradFrom: 'rgba(188, 92, 255, 0.5)',
purpleAreaGradTo: 'rgba(188, 92, 255, 0)',
purpleShadowLineDarkBg: '#a695ff',

// blue line
blueLineGradFrom: '#3bb0ff',
blueLineGradTo: '#0089ff',
blueLineShadow: 'rgba(14, 16, 48, 0.4)',

blueAreaGradFrom: 'rgba(4, 126, 230, 1)',
blueAreaGradTo: 'rgba(4, 126, 230, 0)',
blueShadowLineDarkBg: '#018dff',
},
},
};
46 changes: 46 additions & 0 deletions src/app/@theme/styles/theme.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,51 @@ export const DEFAULT_THEME = {
axisLineColor: '#cccccc',
textColor: '#484848',
},

// TODO: need design for default theme
orders: {
tooltipBg: 'rgba(0, 255, 170, 0.35)',
tooltipLineColor: 'rgba(255, 255, 255, 0.1)',
tooltipLineWidth: '1',
tooltipBorderColor: '#00d977',
tooltipExtraCss: 'box-shadow: 0px 2px 46px 0 rgba(0, 255, 170, 0.35); border-radius: 10px; padding: 8px 24px;',
tooltipTextColor: '#ffffff',
tooltipFontWeight: 'normal',

axisLineColor: 'rgba(161, 161 ,229, 0.3)',
xAxisTextColor: '#a1a1e5',
yAxisSplitLine: 'rgba(161, 161 ,229, 0.2)',

itemBorderColor: '#ffffff',
lineStyle: 'solid',
lineWidth: '6',

// green line
greenLineGradFrom: '#00bece',
greenLineGradTo: '#00da78',
greenLineShadow: 'rgba(14, 16, 48, 0.4)',

greenAreaGradFrom: 'rgba(31 ,106, 124, 0.5)',
greenAreaGradTo: 'rgba(4, 126, 230, 0)',
greenShadowLineDarkBg: '#2c5a85',

// purple line
purpleLineGradFrom: '#8069ff',
purpleLineGradTo: '#8357ff',
purpleLineShadow: 'rgba(14, 16, 48, 0.4)',

purpleAreaGradFrom: 'rgba(188, 92, 255, 0.5)',
purpleAreaGradTo: 'rgba(188, 92, 255, 0)',
purpleShadowLineDarkBg: '#a695ff',

// blue line
blueLineGradFrom: '#3bb0ff',
blueLineGradTo: '#0089ff',
blueLineShadow: 'rgba(14, 16, 48, 0.4)',

blueAreaGradFrom: 'rgba(4, 126, 230, 1)',
blueAreaGradTo: 'rgba(4, 126, 230, 0)',
blueShadowLineDarkBg: '#018dff',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<li class="dropdown-item" *ngFor="let t of types" (click)="type = t">{{ t }}</li>
</ul>
</div>

</div>
<ngx-electricity-chart></ngx-electricity-chart>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="chart-header">
<div class="legends">
<div *ngFor="let legend of chartLegend" class="legend">
<div class="legend-item-color" [ngClass]="legend.styleClass"></div>
<div class="legend-title">{{ legend.title }}</div>
</div>
</div>

<div class="dropdown"
[ngClass]="{ 'ghost-dropdown': currentTheme === 'corporate' }"
ngbDropdown>
<button type="button" ngbDropdownToggle class="btn"
[ngClass]="{ 'btn-outline-success': currentTheme == 'default', 'btn-primary': currentTheme != 'default'}">
{{ type }}
</button>
<ul class="dropdown-menu" ngbDropdownMenu>
<li class="dropdown-item" *ngFor="let period of types" (click)="changePeriod(period)">{{ period }}</li>
</ul>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@import '../../../../@theme/styles/themes';

$legend-all-orders-color: #00977e;
$legend-payment-color: #6935ca;
$legend-canceled-color: #3f4fda;

@include nb-install-component() {

.chart-header {
display: flex;
justify-content: space-between;
margin-bottom: 2.125rem;
}

.legends {
display: flex;
color: nb-theme(color-fg);
padding: 0 1.5rem;
margin-left: 1.25rem;
}

.legend {
display: flex;
justify-content: space-between;
align-items: center;
margin-left: 4rem;

&:first-child {
margin-left: 0;
}
}

.legend-item-color {
height: 0.875rem;
width: 0.875rem;

&.legend-all-orders {
box-shadow: 0 3px 0 $legend-all-orders-color;
background: linear-gradient(90deg, #00c7c7 0%, #00d977 100%);
}

&.legend-payment {
box-shadow: 0 3px 0 $legend-payment-color;
background: linear-gradient(90deg, #a454ff 0%, #7659ff 100%);
}

&.legend-canceled {
box-shadow: 0 3px 0 $legend-canceled-color;
background: linear-gradient(90deg, #0088ff 0%, #3dafff 100%);
}
}

.legend-title {
padding-left: 0.75rem;
}

.dropdown {
min-width: 8.125rem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {Component, EventEmitter, Input, OnDestroy, Output} from '@angular/core';
import { NbThemeService } from '@nebular/theme';
import { takeWhile } from 'rxjs/operators';

@Component({
selector: 'ngx-chart-header',
styleUrls: ['./charts-header.component.scss'],
templateUrl: './charts-header.component.html',
})
export class ChartsHeaderComponent implements OnDestroy {
private alive = true;

@Output() periodChange = new EventEmitter<string>();

@Input() type: string = 'week';
types: string[] = ['week', 'month', 'year'];

chartLegend: {styleClass: string; title: string}[] = [
{
styleClass: 'legend-all-orders',
title: 'All orders',
},
{
styleClass: 'legend-payment',
title: 'Payment',
},
{
styleClass: 'legend-canceled',
title: 'Canceled',
},
];

currentTheme: string;

constructor(private themeService: NbThemeService) {
this.themeService.getJsTheme()
.pipe(takeWhile(() => this.alive))
.subscribe(theme => {
this.currentTheme = theme.name;
});
}

changePeriod(period: string): void {
this.type = period;
this.periodChange.emit(period);
}

ngOnDestroy() {
this.alive = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<nb-card size="medium">
<nb-tabset fullWidth (changeTab)="changeTab($event)">
<nb-tab tabTitle="Orders">
<div class="chart-container">
<ngx-chart-header [type]="period" (periodChange)="setPeriod($event)"></ngx-chart-header>
<ngx-orders-chart #ordersChart [period]="period"></ngx-orders-chart>
</div>
</nb-tab>
<nb-tab tabTitle="Profit" [lazyLoad]="true">
<div class="chart-container">
<ngx-chart-header [type]="period" (periodChange)="setPeriod($event)"></ngx-chart-header>
<ngx-profit-chart #profitChart></ngx-profit-chart>
</div>
</nb-tab>
</nb-tabset>
</nb-card>
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@import '../../../@theme/styles/themes';

$legend-all-orders-color: #00977e;
$legend-payment-color: #6935ca;
$legend-canceled-color: #3f4fda;

@include nb-install-component() {

nb-tabset {
Expand All @@ -12,4 +16,12 @@
flex: 1;
padding: 1.25rem;
}

.chart-container {
flex: 1;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
}
}
34 changes: 20 additions & 14 deletions src/app/pages/ec-dashboard/charts-panel/charts-panel.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { Component } from '@angular/core';
import {Component, ViewChild} from '@angular/core';
import { OrdersChartComponent } from './charts/orders-chart.component';
import { ProfitChartComponent } from './charts/profit-chart.component';

@Component({
selector: 'ngx-ec-charts',
styleUrls: ['./charts-panel.component.scss'],
template: `
<nb-card size="medium">
<nb-tabset fullWidth>
<nb-tab tabTitle="Orders">
<ngx-orders-chart></ngx-orders-chart>
</nb-tab>
<nb-tab tabTitle="Profit">
<ngx-profit-chart></ngx-profit-chart>
</nb-tab>
</nb-tabset>
</nb-card>
`,
templateUrl: './charts-panel.component.html',
})
export class EcChartsPanelComponent {
period: string = 'week';

@ViewChild('ordersChart') ordersChart: OrdersChartComponent;
@ViewChild('profitChart') profitChart: ProfitChartComponent;

setPeriod(value: string): void {
this.period = value;
}

changeTab(selectedTab) {
if (selectedTab.tabTitle === 'Profit') {
this.profitChart.resizeChart();
} else {
this.ordersChart.resizeChart();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
height: 100%;
width: 100%;

/deep/ chart {
.echart {
display: block;
height: 100%;
width: 100%;
Expand Down
Loading

0 comments on commit 730fa9c

Please sign in to comment.