Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Support monthly indicators in line graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
fungjj92 committed Oct 21, 2016
1 parent 07a97e6 commit 43a9729
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/charts/line-graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export class LineGraphComponent {
this.host = D3.select(this.element.nativeElement);
this.timeOptions = {
'yearly': '%Y',
'daily': '%Y-%m-%d'
'daily': '%Y-%m-%d',
'monthly': '%Y-%m'
}
}

Expand Down Expand Up @@ -103,8 +104,6 @@ export class LineGraphComponent {
if (this.extractedData[365] && this.extractedData[365]['date'] == null) {
this.extractedData.pop();
}
// Parse out avg data for ease of use later
this.yData = _.map(this.extractedData, d => d.values.avg);
}

/* Will setup the chart basics */
Expand Down Expand Up @@ -132,6 +131,12 @@ export class LineGraphComponent {
// Time scales only recognize annual and daily data
var parseTime = D3.timeParse(this.timeFormat);
this.extractedData.forEach(d => d.date = parseTime(d.date));

// Sort data by date ascending
this.extractedData.sort(function(a, b) {return a.date - b.date;});
// Parse out avg data for ease of use later
this.yData = _.map(this.extractedData, d => d.values.avg);

this.xRange = D3.extent(this.extractedData, d => d.date);
this.xScale.domain(this.xRange);

Expand Down

0 comments on commit 43a9729

Please sign in to comment.