diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/chart/chart.container.js | 26 | ||||
| -rw-r--r-- | client/index.js | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/client/chart/chart.container.js b/client/chart/chart.container.js index ea86f998..aa80100e 100644 --- a/client/chart/chart.container.js +++ b/client/chart/chart.container.js @@ -107,17 +107,17 @@ class ChartContainer extends Component { ) ) - const maxCitationsInAYear = citationCountsByYear - .slice(1) - .reduce((a,b) => ( - Math.max( - a, - b.slice(1).reduce((a2, b2) => ( - a2 + b2 - ), - 0) - ) - ), 0) + let maxCitationsInAYear = 0 + let currentSum = 0 + // for each year... + for (let j = 1; j < citationCountsByYear[0].length; j++) { + // for each country + currentSum = 0 + for (let i = 1; i < citationCountsByYear.length; i++) { + currentSum += citationCountsByYear[i][j] + } + maxCitationsInAYear = Math.max(currentSum, maxCitationsInAYear) + } let ticks = [] for (let i = 0; i < maxCitationsInAYear; i += 50) { @@ -149,7 +149,7 @@ class ChartContainer extends Component { tick: { values: ticks, }, - default: [ 0, maxCitationsInAYear ], + default: [ 0, maxCitationsInAYear * 286 / 261 ], show: true, } }} @@ -165,7 +165,7 @@ class ChartContainer extends Component { let countriesByYear = Object.keys(countriesByYearLookup).map(country => [country, countriesByYearLookup[country]]).sort((a,b) => b[1] - a[1]) let topCountriesForThisYear = countriesByYear.slice(0, topCountryCount) let bottomTotal = countriesByYear.slice(topCountryCount).reduce((a,b) => (a + b[1]), 0) - console.log(topCountriesForThisYear) + // console.log(topCountriesForThisYear) topCountriesForThisYear.push([otherCountriesLabel, bottomTotal]) const tableRows = topCountriesForThisYear.filter(pair => !!pair[1]).map(([country, total]) => { let colorIndex = topCountries.indexOf(country) diff --git a/client/index.js b/client/index.js index 87214925..dd60c0ed 100644 --- a/client/index.js +++ b/client/index.js @@ -89,8 +89,8 @@ function runApplets() { } console.log('dataset from path:', dataset) } else { - console.log('couldnt determine citations dataset') - return null + console.log('not on a dataset page') + return [el, payload] } } payload.dataset = dataset |
