Skip to content

Commit a6e7069

Browse files
authored
Merge pull request #614 from OpenKnowledgeMaps/dev
Biweekly release (22-01-20)
2 parents 0cd2c50 + 36aaf37 commit a6e7069

48 files changed

Lines changed: 3192 additions & 3253 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 2022-01-20
4+
5+
### New features
6+
7+
- backend data sanitization
8+
- pdfs searchable by the searchbox
9+
10+
### Changes
11+
12+
- data preprocessing refactoring
13+
14+
### Bug fixes
15+
16+
- footer size on narrow screens
17+
18+
### Internal
19+
20+
- test database update
21+
322
## 2021-12-22
423

524
### Changes

server/storage/test.sqlite

1.43 MB
Binary file not shown.

vis/js/actions/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,33 @@ export const preinitializeStore = (configObject) => ({
6060
* Action for initializing the data that aren't known in advance.
6161
* @param {Object} configObject the default_config.json + data_config.json
6262
* @param {Object} contextObject the app context
63-
* @param {Array} dataArray the papers data
63+
* @param {Array} papers the papers data array
64+
* @param {Array} areas the areas data array
65+
* @param {Array} streams the streams data array
6466
*/
6567
export const initializeStore = (
6668
configObject,
6769
contextObject,
68-
dataArray,
69-
streamData,
70+
papers,
71+
areas,
72+
streams,
7073
chartSize,
7174
streamWidth,
7275
streamHeight,
73-
listHeight
76+
listHeight,
77+
scalingFactors
7478
) => ({
7579
type: "INITIALIZE",
7680
configObject,
7781
contextObject,
78-
dataArray,
79-
streamData,
82+
papers,
83+
areas,
84+
streams,
8085
chartSize,
8186
streamWidth,
8287
streamHeight,
8388
listHeight,
89+
scalingFactors,
8490
});
8591

8692
/**

vis/js/components/Streamgraph.js

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
getLabelPosition,
1212
recalculateOverlappingLabels,
1313
setTM,
14-
transformData,
1514
} from "../utils/streamgraph";
1615
import {
1716
CHART_MARGIN,
@@ -37,15 +36,6 @@ class Streamgraph extends React.Component {
3736
constructor(props) {
3837
super(props);
3938

40-
this.stack = d3.layout
41-
.stack()
42-
.offset("silhouette")
43-
.values((d) => d.values)
44-
.x((d) => d.date)
45-
.y((d) => d.value);
46-
47-
this.nest = d3.nest().key((d) => d.key);
48-
4939
this.labelPositions = [];
5040
}
5141

@@ -71,16 +61,18 @@ class Streamgraph extends React.Component {
7161
const { colors } = this.props;
7262
const { width, height } = this.getDimensions();
7363

74-
const parsedData = JSON.parse(this.props.data);
75-
const transformedData = transformData(parsedData);
76-
const streams = this.getStreams(transformedData);
77-
7864
const xScale = d3.time.scale().range([0, width]);
7965
const yScale = d3.scale.linear().range([height, 0]);
8066
const colorScale = d3.scale.ordinal().range(colors);
8167

82-
xScale.domain(d3.extent(transformedData, (d) => d.date));
83-
yScale.domain([0, d3.max(transformedData, (d) => d.y0 + d.y)]);
68+
const streams = this.props.streams;
69+
const streamEntries = streams.reduce(
70+
(l, stream) => [...l, ...stream.values],
71+
[]
72+
);
73+
74+
xScale.domain(d3.extent(streamEntries, (d) => d.date));
75+
yScale.domain([0, d3.max(streamEntries, (d) => d.y0 + d.y)]);
8476

8577
const area = d3.svg
8678
.area()
@@ -94,7 +86,7 @@ class Streamgraph extends React.Component {
9486

9587
this.renderBackground(container, width, height);
9688
this.renderStreams(container, streams, area, colorScale);
97-
this.renderAxes(container, parsedData, xScale, yScale, width, height);
89+
this.renderAxes(container, streams, xScale, yScale, width, height);
9890
this.renderLabels(container, xScale, yScale, width);
9991
this.renderTooltip(container, xScale);
10092
this.renderLineHelper(container);
@@ -159,19 +151,19 @@ class Streamgraph extends React.Component {
159151
* Renders the graph axes using d3.
160152
*
161153
* @param {Object} container the d3 representation of #streamgraph-chart
162-
* @param {Object} parsedData the parsed JSON containing the streamgraph data
154+
* @param {Object} streams the stream array
163155
* @param {Function} xScale x coordinate scaling function
164156
* @param {Function} yScale y coordinate scaling function
165157
* @param {number} width graph width
166158
* @param {number} height graph height
167159
*/
168-
renderAxes(container, parsedData, xScale, yScale, width, height) {
160+
renderAxes(container, streams, xScale, yScale, width, height) {
169161
const xAxis = d3.svg
170162
.axis()
171163
.scale(xScale)
172164
.orient("bottom")
173165
.tickFormat(d3.time.format("%Y"))
174-
.ticks(d3.time.year, Math.ceil(parsedData.x.length / MAX_TICKS_X));
166+
.ticks(d3.time.year, Math.ceil(streams.length / MAX_TICKS_X));
175167

176168
const yAxis = d3.svg
177169
.axis()
@@ -509,28 +501,10 @@ class Streamgraph extends React.Component {
509501

510502
return { width, height };
511503
}
512-
513-
getStreams(transformedData) {
514-
const nestedEntries = this.nest.entries(transformedData);
515-
const streams = this.stack(nestedEntries);
516-
517-
streams.forEach((stream) => {
518-
const firstTransformedEntry = transformedData.find(
519-
(t) => t.key === stream.key
520-
);
521-
if (!firstTransformedEntry) {
522-
stream.docIds = [];
523-
return;
524-
}
525-
stream.docIds = firstTransformedEntry.docIds;
526-
});
527-
528-
return streams;
529-
}
530504
}
531505

532506
const mapStateToProps = (state) => ({
533-
data: state.streamgraph.data,
507+
streams: state.streamgraph.streams,
534508
colors: state.streamgraph.colors,
535509
width: state.chart.streamWidth,
536510
height: state.chart.streamHeight,

0 commit comments

Comments
 (0)