Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet Management] Cost tab fixes #57

Open
wants to merge 3 commits into
base: vnext
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
<div class="chart-container pie-chart-container">
<div class="chart-header">
<span class="chart-title">Costs per Type</span>
<igx-select #select class="chart-select" [value]="periods.costPerTypePeriod" (selectionChanging)="onPeriodChange($event, 'costsPerType')">
<igx-select #select class="chart-select" [value]="periods[dataItem.vehicleId]?.costPerTypePeriod || Period.YTD"
(selectionChanging)="onPeriodChange($event, 'costsPerType', dataItem.vehicleId)">
<label igxLabel>Period</label>
<igx-select-item [value]="Period.YTD">YTD</igx-select-item>
<igx-select-item [value]="Period.ThreeMonths">Last 3 Months</igx-select-item>
Expand All @@ -132,7 +133,7 @@
valueMemberPath="value"
labelsPosition="OutsideEnd"
radiusFactor="0.7"
[dataSource]="dataService.getCostsPerTypeData(dataItem.vehicleId, periods.costPerTypePeriod)"
[dataSource]="dataService.getCostsPerTypeData(dataItem.vehicleId, periods[dataItem.vehicleId]?.costPerTypePeriod || Period.YTD)"
actualLabelOuterColor="#ededed"
>
</igx-pie-chart>
Expand All @@ -142,7 +143,8 @@
<div class="chart-container area-chart-container">
<div class="chart-header">
<span class="chart-title">Costs per Meter, per Quarter</span>
<igx-select #select class="chart-select" [value]="periods.costPerMeterPeriod" (selectionChanging)="onPeriodChange($event, 'costsPerMeter')">
<igx-select #select class="chart-select" [value]="periods[dataItem.vehicleId]?.costPerMeterPeriod || Period.YTD"
(selectionChanging)="onPeriodChange($event, 'costsPerMeter', dataItem.vehicleId)">
<label igxLabel>Period</label>
<igx-select-item value="ytd">YTD</igx-select-item>
<igx-select-item value="'2023'">2023</igx-select-item>
Expand All @@ -155,7 +157,7 @@
<igx-category-chart
name="chart"
class="chart-canvas"
[dataSource]="dataService.getCostsPerMeterData(dataItem.vehicleId, periods.costPerMeterPeriod)"
[dataSource]="dataService.getCostsPerMeterData(dataItem.vehicleId, periods[dataItem.vehicleId]?.costPerMeterPeriod || Period.YTD)"
chartType="Area"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
Expand All @@ -174,7 +176,8 @@
<div class="chart-container column-chart-container">
<div class="chart-header">
<span class="chart-title">Fuel Costs per Month</span>
<igx-select #select class="chart-select" [value]="periods.fuelCostPeriod" (selectionChanging)="onPeriodChange($event, 'fuelCosts')">
<igx-select #select class="chart-select" [value]="periods[dataItem.vehicleId]?.fuelCostPeriod || Period.YTD"
(selectionChanging)="onPeriodChange($event, 'fuelCosts', dataItem.vehicleId)">
<label igxLabel>Period</label>
<igx-select-item [value]="Period.YTD">YTD</igx-select-item>
<igx-select-item [value]="Period.ThreeMonths">Last 3 Months</igx-select-item>
Expand All @@ -188,7 +191,7 @@
class="column-chart"
#chart
chartType="Column"
[dataSource]="dataService.getFuelCostsData(dataItem.vehicleId, periods.fuelCostPeriod)"
[dataSource]="dataService.getFuelCostsData(dataItem.vehicleId, periods[dataItem.vehicleId]?.fuelCostPeriod || Period.YTD)"
yAxisTitle="Costs in USD"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

:root {
--primary-text-color: #f5f5f5;
--default-border: 1px solid #8A8A8A;
}

:host {
Expand Down Expand Up @@ -94,7 +93,7 @@ igx-card {
height: 100%;
padding: 15px;
border-radius: 6px;
border: var(--default-border);
border: 1px solid #8A8A8A;
}

.content-wrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ export class FleetManagementGridComponent implements OnInit {

//chart periods
protected Period = Period;
protected periods = {
/* protected periods = {
costPerTypePeriod: Period.YTD,
costPerMeterPeriod: Period.YTD,
fuelCostPeriod: Period.YTD
}
} */
protected periods: { [vehicleId: string]: { costPerTypePeriod: Period, costPerMeterPeriod: Period, fuelCostPeriod: Period } } = {};

//driver details for detail overlay
protected driverDetails: DriverDetails = {
Expand Down Expand Up @@ -140,13 +141,21 @@ export class FleetManagementGridComponent implements OnInit {
}

//handling for chart periods
protected onPeriodChange(event: any, chart: string): void {
protected onPeriodChange(event: any, chart: string, vehicleId: string): void {
if (!this.periods[vehicleId]) {
this.periods[vehicleId] = {
costPerTypePeriod: Period.YTD,
costPerMeterPeriod: Period.YTD,
fuelCostPeriod: Period.YTD
};
}

if (chart === ChartType.CostPerType) {
this.periods.costPerTypePeriod = event.newSelection.value;
this.periods[vehicleId].costPerTypePeriod = event.newSelection.value;
} else if (chart === ChartType.CostPerMeter) {
this.periods.costPerMeterPeriod = event.newSelection.value;
this.periods[vehicleId].costPerMeterPeriod = event.newSelection.value;
} else if (chart === ChartType.FuelCosts) {
this.periods.fuelCostPeriod = event.newSelection.value;
this.periods[vehicleId].fuelCostPeriod = event.newSelection.value;
}

}
Expand Down
Loading