-
Notifications
You must be signed in to change notification settings - Fork 0
/
stepFunctionsDownard.js
96 lines (81 loc) · 2.15 KB
/
stepFunctionsDownard.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import {
drawAxes,
drawSecondaryAxes,
drawBar,
removeBar,
stackedBarChart,
fadeBarsOut,
fadeBarsIn,
drawAllBars,
cleanupZeroBars,
fillMissingBars,
middleBarsDown,
middleBarsDownFinalState,
forceChart,
middleBarsDownReverse,
forceChartReverse,
removeAxesFade,
createSVG,
} from "./graphFunctions.js";
import { totalMdVolume } from "./data/dataPrep.js";
import textStory from "./textStory.js";
import cra from "./data/craData.js";
let lastUpwardEventFinished;
export const changeEventsDownard = {
intro: introFunctions,
year2006: drawYearFunctions,
year2007: drawYearFunctions,
year2008: drawYearFunctions,
year2009: drawYearFunctions,
year2010: drawYearFunctions,
year2011: drawYearFunctions,
year2012: drawYearFunctions,
year2013: drawYearFunctions,
year2014: drawYearFunctions,
year2015: drawYearFunctions,
year2016: drawYearFunctions,
year2017: drawYearFunctions,
year2018: drawYearFunctions,
year2019: drawYearFunctions,
year2020: drawYearFunctions,
classBreakdown: fromRegToStacked,
firstAndLast: firstAndLastFunctions,
productLevel: forceChartFunctions,
};
function introFunctions() {
createSVG();
drawAxes();
// drawAllBars(totalMdVolume);
}
function drawYearFunctions(totalMdVolume, currentYear) {
drawBar(totalMdVolume, currentYear);
setTimeout(() => {
if (currentYear === 2020) {
drawAllBars(totalMdVolume);
}
}, 900);
}
function firstAndLastFunctions() {
d3.selectAll(".bar").remove();
stackedBarChart(cra, "allYears");
d3.selectAll(".bar").style("opacity", 1);
middleBarsDown();
}
function forceChartFunctions() {
d3.selectAll(".bar").remove();
stackedBarChart(cra, "outsideYears");
d3.selectAll(".bar").style("opacity", 1);
forceChart();
removeAxesFade();
}
function fromRegToStacked() {
d3.select("svg").remove();
createSVG();
drawAxes();
drawAllBars(totalMdVolume);
d3.selectAll(".reg").style("opacity", 1);
d3.selectAll(".reg").transition().duration(1500).style("opacity", 0);
stackedBarChart(cra, "allYears");
d3.selectAll(".stacked").style("opacity", 0);
d3.selectAll(".stacked").transition().duration(1500).style("opacity", 1);
}