0% found this document useful (0 votes)
12 views2 pages

Auction Graph Code

The document outlines the implementation of an Angular component for a dialog related to auction types. It includes methods for initializing auction details, handling user data, and updating chart options based on fetched auction bid details. The component also manages the lifecycle of the dialog and cleans up resources when closed.

Uploaded by

DQS INDIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Auction Graph Code

The document outlines the implementation of an Angular component for a dialog related to auction types. It includes methods for initializing auction details, handling user data, and updating chart options based on fetched auction bid details. The component also manages the lifecycle of the dialog and cleans up resources when closed.

Uploaded by

DQS INDIA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import { Component, Inject, OnInit, OnDestroy } from '@angular/core';

import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';


import { AuctionserviceService } from '../Service/auctionservice.service';

@Component({
selector: 'app-auctiontypedialog',
templateUrl: './auctiontypedialog.component.html',
styleUrls: ['./auctiontypedialog.component.scss']
})
export class AuctiontypedialogComponent implements OnInit, OnDestroy {
companyId: number | null = null;
employeeLoginId: number | null = null;
auctionTypeName: string = 'Forward Auction';
dps: { x: number; y: number; label?: string }[] = [];
intervalId: any;
rowData: any = [];
Bids: any;

chartOptions: any = {
animationEnabled: true,
theme: "light2",
title: {
text: "Forward Auction"
},
axisX: {
title: "Time",
interval: 1,
titleFontColor: "#c02e48",
labelFontColor: "black",
lineColor: "#c02e48",
tickColor: "#c02e48",
},
axisY: {
title: "Price",
minimum: 0,
titleFontColor: "#c02e48",
labelFontColor: "black",
lineColor: "#c02e48",
tickColor: "#c02e48",
},
data: [{
type: "line",
name: "Auction Price",
showInLegend: true,
yValueFormatString: "#,###$",
titleFontColor: "#c02e48",
labelFontColor: "black",
lineColor: "#c02e48",
tickColor: "#c02e48",
color: "#c02e48",
dataPoints: []
}]
};

constructor(
public dialogRef: MatDialogRef<AuctiontypedialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
private auctionService: AuctionserviceService
) {}
ngOnInit(): void {
const storedData = localStorage.getItem('user_details') ?? "{}";
const userDetails = JSON.parse(storedData);

if (userDetails && userDetails.companyId) {


this.companyId = userDetails.companyId;
this.employeeLoginId = userDetails.employeeId;
}
this.getAuctionDetails();
}

ngOnDestroy(): void {
if (this.intervalId) clearInterval(this.intervalId);
}

closePage() {
if (this.intervalId) clearInterval(this.intervalId);
this.dialogRef.close();
}

getAuctionDetails() {
this.auctionService.getAuctionBidDetails(this.data?.auction_id).subscribe(
(res: any) => {
if (res.body) {
console.log(res.body, 'ATTTTTTTTS')
this.rowData = res.body.vendorBidDetails;
this.Bids = res.body.bids[0];

const filteredData = res.body.vendorBidDetails.filter(


(auction: any) => auction.AuctionType_name === "Forward Auction"
);

this.dps = filteredData.map((auction: any, index: number) => ({


x: index + 1,
y: Number(auction.total_bid_amount), // Ensure it's a number
label: auction.supplierName || "No Vendor",
}));

this.chartOptions = {
...this.chartOptions,
data: [{
type: "line",
name: "Auction Price Time Graph",
showInLegend: true,
yValueFormatString: "#,###$",
dataPoints: this.dps
}]
};
}
},
(err) => {
console.error("Error fetching auction details", err);
}
);
}
}

You might also like