-
Notifications
You must be signed in to change notification settings - Fork 1
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
Convert available funds / contributions/expenditures from area to step charts #216
base: main
Are you sure you want to change the base?
Changes from 1 commit
3da50d3
e5796ec
8c7b59a
26d670d
8a95238
4338d93
99fca26
f21a76e
16dfa3d
a3f98a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ ChartHelper.netfunds = function(el, title, sourceTxt, yaxisLabel, data, startYea | |
return new Highcharts.Chart({ | ||
chart: { | ||
renderTo: el, | ||
type: "line", | ||
type: "area", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you turn this back to area? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops! |
||
}, | ||
legend: { | ||
backgroundColor: "#ffffff", | ||
|
@@ -127,13 +127,13 @@ ChartHelper.netfunds = function(el, title, sourceTxt, yaxisLabel, data, startYea | |
}, | ||
title: null, | ||
xAxis: { | ||
dateTimeLabelFormats: { year: "%Y" }, | ||
dateTimeLabelFormats: { year: "%b '%y" }, | ||
type: "datetime", | ||
title: { | ||
enabled: true, | ||
text: "Filing date" | ||
text: "Filing period end date" | ||
}, | ||
tickPixelInterval: 50, | ||
tickPixelInterval: 75, | ||
min: Date.UTC(startYear, 1, 1), | ||
max: Date.UTC(endYear+1, 1, 1), | ||
startOnTick: true, | ||
|
@@ -168,9 +168,16 @@ ChartHelper.netfunds = function(el, title, sourceTxt, yaxisLabel, data, startYea | |
}, | ||
tooltip: { | ||
crosshairs: true, | ||
useHTML: true, | ||
formatter: function() { | ||
var s = "<strong>" + ChartHelper.toolTipDateFormat("day", this.x) + "</strong>"; | ||
let s = "" | ||
$.each(this.points, function(i, point) { | ||
if (i === 0) { | ||
s += ` | ||
<strong>${point.point.description}</strong><br /> | ||
<strong>Period ending ${ChartHelper.toolTipDateFormat("day", this.x)}</strong> | ||
` | ||
} | ||
s += "<br /><span style='color: " + point.series.color + "'>" + point.series.name + ":</span> $" + Highcharts.numberFormat(point.y, 0, '.', ','); | ||
}); | ||
return s; | ||
|
@@ -199,7 +206,7 @@ ChartHelper.donation_expenditure = function(el, title, sourceTxt, yaxisLabel, da | |
return new Highcharts.Chart({ | ||
chart: { | ||
renderTo: el, | ||
type: "line", | ||
type: "area", | ||
}, | ||
legend: { | ||
backgroundColor: "#ffffff", | ||
|
@@ -218,7 +225,7 @@ ChartHelper.donation_expenditure = function(el, title, sourceTxt, yaxisLabel, da | |
enabled: true, | ||
text: "Month", | ||
}, | ||
tickPixelInterval: 50, | ||
tickPixelInterval: 75, | ||
min: Date.UTC(startYear, 1, 1), | ||
max: Date.UTC(endYear+1, 1, 1), | ||
startOnTick: true, | ||
|
@@ -250,6 +257,7 @@ ChartHelper.donation_expenditure = function(el, title, sourceTxt, yaxisLabel, da | |
}, | ||
tooltip: { | ||
crosshairs: true, | ||
useHTML: true, | ||
formatter: function() { | ||
var s = "<strong>" + ChartHelper.toolTipDateFormat("month", this.x) + "</strong>"; | ||
$.each(this.points, function(i, point) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,42 +245,62 @@ <h1><i class='fa fa-spin fa-circle-o-notch'></i></h1> | |
} | ||
|
||
//render net balance chart | ||
var balance_trend = {{balance_trend}}; | ||
var balance_trend = {{balance_trend|safe}}; | ||
var balance_trend_f = []; | ||
var debt_trend = {{debt_trend}}; | ||
|
||
var debt_trend = {{debt_trend|safe}}; | ||
var debt_trend_f = []; | ||
|
||
// format balances | ||
for (i = 0; i < balance_trend.length; i++) { | ||
balance_trend_f.push([Date.UTC(balance_trend[i][1],balance_trend[i][2]-1,balance_trend[i][3]), balance_trend[i][0]]); | ||
} | ||
var expend_trend = {{expend_trend|safe}}; | ||
var expend_trend_f = []; | ||
|
||
// format debt | ||
for (i = 0; i < debt_trend.length; i++) { | ||
debt_trend_f.push([Date.UTC(debt_trend[i][1],debt_trend[i][2]-1,debt_trend[i][3]), debt_trend[i][0]]); | ||
} | ||
var donation_trend = {{donation_trend|safe}}; | ||
var donation_trend_f = []; | ||
|
||
ChartHelper.netfunds('net-funds-chart', 'Funds available and debts by filing date', '', 'Funds available / Debts', [balance_trend_f, debt_trend_f], balance_trend[0][1], balance_trend[balance_trend.length - 1][1]); | ||
balance_trend.forEach(function(bal) { | ||
balance_trend_f.push({ | ||
y: bal.amount, | ||
x: Date.UTC(bal.year, bal.month-1, bal.day), | ||
description: bal.description, | ||
}) | ||
}) | ||
|
||
debt_trend.forEach(function(debt) { | ||
debt_trend_f.push({ | ||
y: debt.amount, | ||
x: Date.UTC(debt.year, debt.month-1, debt.day), | ||
description: debt.description, | ||
}) | ||
}) | ||
|
||
//render donation/expenditure chart | ||
var expend_trend = {{expend_trend}}; | ||
var expend_trend_f = []; | ||
expend_trend.forEach(function(exp) { | ||
expend_trend_f.push({ | ||
y: exp.amount, | ||
x: Date.UTC(exp.year, exp.month-1), | ||
}) | ||
}) | ||
|
||
var donation_trend = {{donation_trend}}; | ||
var donation_trend_f = []; | ||
donation_trend.forEach(function(don) { | ||
donation_trend_f.push({ | ||
y: don.amount, | ||
x: Date.UTC(don.year, don.month-1), | ||
description: don.description, | ||
}) | ||
}) | ||
|
||
// format donations | ||
for (i = 0; i < donation_trend.length; i++) { | ||
donation_trend_f.push([Date.UTC(donation_trend[i][1],donation_trend[i][2]-1,donation_trend[i][3]), donation_trend[i][0]]); | ||
} | ||
const chartValues = Array.prototype.concat(balance_trend, debt_trend, expend_trend, donation_trend) | ||
|
||
// format expenditures | ||
for (i = 0; i < expend_trend.length; i++) { | ||
expend_trend_f.push([Date.UTC(expend_trend[i][1],expend_trend[i][2]-1,expend_trend[i][3]), expend_trend[i][0]]); | ||
} | ||
const startYear = chartValues.reduce(function(prev, current) { | ||
return (prev && prev.year > current.year) ? current : prev | ||
}).year | ||
|
||
const endYear = chartValues.reduce(function(prev, current) { | ||
return (prev && prev.year > current.year) ? prev : current | ||
}).year | ||
Comment on lines
-274
to
+299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calculate start and end year across all chart data, to ensure consistency. |
||
|
||
ChartHelper.netfunds('net-funds-chart', 'Funds available and debts by filing period', '', 'Funds available / Debts', [balance_trend_f, debt_trend_f], startYear, endYear); | ||
|
||
ChartHelper.donation_expenditure('expend-chart', 'Contributions and expenditures by month', '', 'Contributions / Expenditures', [donation_trend_f, expend_trend_f], donation_trend[0][1], donation_trend[donation_trend.length - 1][1]); | ||
ChartHelper.donation_expenditure('expend-chart', 'Contributions and expenditures by month', '', 'Contributions / Expenditures', [donation_trend_f, expend_trend_f], startYear, endYear); | ||
</script> | ||
<script type="text/javascript"> | ||
function getPersonName(object){ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now returning lists of dictionaries, in order to pass filing description through to the view. I don't see that
trends
is used anywhere else, besides the deprecated races view.