Skip to content

Commit

Permalink
Merge pull request #1432 from ORNL-AMO/issue-1171
Browse files Browse the repository at this point in the history
quick fix dates on stacked bar chart
  • Loading branch information
rmroot authored Jan 25, 2024
2 parents 16e0472 + 9f5d288 commit 0bf046a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export class EmissionsStackedLineChartComponent {
},
xaxis: {
// autotick: false,
// range: xrange
// range: xrange,
type: 'date'
},
yaxis: {
title: {
Expand All @@ -105,18 +106,18 @@ export class EmissionsStackedLineChartComponent {
}

getTraceData(emissionsType: EmissionsTypes, monthlyDataInRange: Array<MonthlyData>) {
let x: Array<string> = new Array();
let x: Array<Date> = new Array();
let y: Array<number> = new Array();
let startDate: Date = new Date(this.dateRange.startDate);
let endDate: Date = new Date(this.dateRange.endDate);
while (startDate < endDate) {
let currentMonthsData: Array<MonthlyData> = monthlyDataInRange.filter(mData => {
return mData.monthNumValue == startDate.getMonth() && mData.year == startDate.getFullYear()
});
let month: Month = Months.find(month => {
return month.monthNumValue == startDate.getMonth();
})
x.push(month.abbreviation + ', ' + startDate.getFullYear());
// let month: Month = Months.find(month => {
// return month.monthNumValue == startDate.getMonth();
// })
x.push(new Date(startDate));
let total: number;
if (emissionsType == 'Scope 1: Fugitive') {
total = _.sumBy(currentMonthsData, (mData: MonthlyData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class MetersOverviewStackedLineChartComponent {
// let dataPointSize: number = 0;
this.calanderizedMeters.forEach(cMeter => {
if (this.checkIncludeMeter(cMeter.meter)) {
let x: Array<string> = new Array();
let x: Array<Date> = new Array();
let y: Array<number> = new Array();
// if (dataPointSize < cMeter.monthlyData.length - 1) {
// dataPointSize = cMeter.monthlyData.length - 1;
Expand All @@ -63,7 +63,7 @@ export class MetersOverviewStackedLineChartComponent {
return (dataItemDate >= this.dateRange.startDate) && (dataItemDate <= this.dateRange.endDate);
});
monthlyDataInRange.forEach(dataItem => {
x.push(dataItem.month + ', ' + dataItem.year);
x.push(dataItem.date);
if (this.dataType == 'energyUse') {
y.push(dataItem.energyUse);
} else if (this.dataType == 'cost') {
Expand Down Expand Up @@ -103,6 +103,7 @@ export class MetersOverviewStackedLineChartComponent {
xaxis: {
// autotick: false,
// range: xrange
type: 'date'
},
yaxis: {
title: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class MonthlyUtilityUsageLineChartComponent {
}
let years: Array<number> = this.yearMonthData.flatMap(data => { return data.yearMonth.fiscalYear });
years = _.uniq(years);
years = _.orderBy(years, (year) => { return year }, 'asc');
let months: Array<Month> = Months.map(month => { return month });
if (accountOrFacility.fiscalYear == 'nonCalendarYear') {
let monthStartIndex: number = months.findIndex(month => { return month.monthNumValue == accountOrFacility.fiscalYearMonth });
Expand Down

0 comments on commit 0bf046a

Please sign in to comment.