-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from nzzdev/release-4.0.0
Release 4.0.0
- Loading branch information
Showing
49 changed files
with
5,051 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
process.env.METHOD_BOX_ARTICLE = `{ | ||
"title": "Mehr zur Datenberechnung der NZZ", | ||
"url": "https://www.nzz.ch/ld.1580452" | ||
}`; | ||
|
||
require("./index.js"); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const methodBoxTextConfig = { | ||
ckmeans: | ||
"Die unterschiedlich grossen Gruppen kommen durch ein statistisches Verfahren zustande, welches die Werte so in Gruppen einteilt, dass die Unterschiede zwischen den Regionen möglichst gut sichtbar werden (Jenks Natural Breaks).", | ||
quantile: | ||
"Die Gruppen wurden so gewählt, dass in jeder Gruppe möglichst gleich viele Werte vorhanden sind.", | ||
equal: | ||
"Die Gruppen wurden so gewählt, dass sie jeweils einen gleich grossen Bereich auf der Skala abdecken.", | ||
custom: "Die Gruppen wurden manuell definiert.", | ||
}; | ||
|
||
function getMethodBoxInfo(bucketType) { | ||
const methodBoxText = methodBoxTextConfig[bucketType]; | ||
return { | ||
text: methodBoxText || "", | ||
article: { "title": "Mehr zur Datenberechnung der NZZ", "url": "https://www.nzz.ch/ld.1580452" } | ||
}; | ||
} | ||
|
||
module.exports = { getMethodBoxInfo }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const dataHelpers = require("./data.js"); | ||
const legendHelpers = require("./colorColumnLegend.js"); | ||
const colorHelpers = require("./colorColumnColor.js"); | ||
const methodBoxHelpers = require("./colorColomnMethodBox.js"); | ||
|
||
function hasCustomBuckets(bucketType) { | ||
return bucketType === "custom"; | ||
} | ||
|
||
function getNumberBuckets(colorColumn) { | ||
try { | ||
if (colorColumn.numericalOptions.bucketType !== "custom") { | ||
return colorColumn.numericalOptions.numberBuckets; | ||
} else { | ||
const bucketBorderValues = getCustomBucketBorders( | ||
colorColumn.numericalOptions.customBuckets | ||
); | ||
return bucketBorderValues.length - 1; // min value is part of border values and has to be excluded here | ||
} | ||
} catch { | ||
return 0; | ||
} | ||
} | ||
|
||
function getColorColumnContext(colorColumn, data, width) { | ||
let colorColumnContext = {}; | ||
if (colorColumn !== null && colorColumn !== undefined && colorColumn.selectedColumn !== null && colorColumn.selectedColumn !== undefined) { | ||
let colors = []; | ||
if (colorColumn.colorColumnType === "numerical") { | ||
|
||
let formattingOptions = { | ||
maxDigitsAfterComma: dataHelpers.getMaxDigitsAfterCommaInDataByRow( | ||
data, colorColumn.selectedColumn | ||
), | ||
roundingBucketBorders: colorColumn.numericalOptions.bucketType !== "custom" | ||
}; | ||
|
||
colorColumnContext.legendData = legendHelpers.getNumericalLegend( | ||
data, | ||
colorColumn, | ||
formattingOptions.maxDigitsAfterComma, | ||
width | ||
); | ||
|
||
colorColumnContext.methodBox = methodBoxHelpers.getMethodBoxInfo( | ||
colorColumn.numericalOptions.bucketType | ||
); | ||
|
||
let valuesByColumn = dataHelpers.getNumericalValuesByColumn(data, colorColumn.selectedColumn); | ||
colorColumnContext.formattedValues = []; | ||
colorColumnContext.methodBox.formattedBuckets = dataHelpers.getFormattedBuckets(formattingOptions, colorColumnContext.legendData.buckets); | ||
valuesByColumn.map(value => { | ||
let color = colorHelpers.getColor(value, colorColumnContext.legendData); | ||
colors = [...colors, color]; | ||
colorColumnContext.formattedValues = [...colorColumnContext.formattedValues, dataHelpers.getFormattedValue(formattingOptions, value)]; | ||
}) | ||
} else { | ||
colorColumnContext.legendData = legendHelpers.getCategoricalLegend( | ||
data, | ||
colorColumn | ||
); | ||
|
||
let categoriesByColumn = dataHelpers.getCategoricalValuesByColumn(data, colorColumn.selectedColumn); | ||
categoriesByColumn.map(category => { | ||
let color = colorHelpers.getColor(category, colorColumnContext.legendData); | ||
colors = [...colors, color]; | ||
}); | ||
} | ||
colorColumnContext = { ...colorColumnContext, ...colorColumn, colors }; | ||
} | ||
return colorColumnContext; | ||
} | ||
|
||
|
||
module.exports = { | ||
getNumberBuckets, | ||
hasCustomBuckets, | ||
getColorColumnContext, | ||
}; |
Oops, something went wrong.