dce-reactkit 1.0.19 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/.eslintrc.js +95 -0
  2. package/lib/components/LoadingSpinner.d.ts +6 -0
  3. package/lib/components/LoadingSpinner.js +41 -0
  4. package/lib/components/LoadingSpinner.js.map +1 -0
  5. package/lib/components/Modal.d.ts +69 -0
  6. package/lib/components/Modal.js +315 -0
  7. package/lib/components/Modal.js.map +1 -0
  8. package/lib/helpers/abbreviate.d.ts +9 -0
  9. package/lib/helpers/abbreviate.js +21 -0
  10. package/lib/helpers/abbreviate.js.map +1 -0
  11. package/lib/helpers/avg.d.ts +8 -0
  12. package/lib/helpers/avg.js +24 -0
  13. package/lib/helpers/avg.js.map +1 -0
  14. package/lib/helpers/ceilToNumDecimals.d.ts +9 -0
  15. package/lib/helpers/ceilToNumDecimals.js +15 -0
  16. package/lib/helpers/ceilToNumDecimals.js.map +1 -0
  17. package/lib/helpers/floorToNumDecimals.d.ts +9 -0
  18. package/lib/helpers/floorToNumDecimals.js +15 -0
  19. package/lib/helpers/floorToNumDecimals.js.map +1 -0
  20. package/lib/helpers/forceNumIntoBounds.d.ts +10 -0
  21. package/lib/helpers/forceNumIntoBounds.js +15 -0
  22. package/lib/helpers/forceNumIntoBounds.js.map +1 -0
  23. package/lib/helpers/padDecimalZeros.d.ts +10 -0
  24. package/lib/helpers/padDecimalZeros.js +30 -0
  25. package/lib/helpers/padDecimalZeros.js.map +1 -0
  26. package/lib/helpers/padZerosLeft.d.ts +9 -0
  27. package/lib/helpers/padZerosLeft.js +21 -0
  28. package/lib/helpers/padZerosLeft.js.map +1 -0
  29. package/lib/helpers/roundToNumDecimals.d.ts +9 -0
  30. package/lib/helpers/roundToNumDecimals.js +15 -0
  31. package/lib/helpers/roundToNumDecimals.js.map +1 -0
  32. package/lib/helpers/sum.d.ts +8 -0
  33. package/lib/helpers/sum.js +15 -0
  34. package/lib/helpers/sum.js.map +1 -0
  35. package/lib/helpers/waitMs.d.ts +7 -0
  36. package/lib/helpers/waitMs.js +55 -0
  37. package/lib/helpers/waitMs.js.map +1 -0
  38. package/lib/types/Variant.d.ts +15 -0
  39. package/lib/types/Variant.js +19 -0
  40. package/lib/types/Variant.js.map +1 -0
  41. package/package.json +21 -39
  42. package/src/components/LoadingSpinner.tsx +105 -0
  43. package/src/components/Modal.tsx +447 -0
  44. package/src/helpers/abbreviate.tsx +23 -0
  45. package/src/helpers/avg.tsx +22 -0
  46. package/src/helpers/ceilToNumDecimals.tsx +13 -0
  47. package/src/helpers/floorToNumDecimals.tsx +13 -0
  48. package/src/helpers/forceNumIntoBounds.tsx +19 -0
  49. package/src/helpers/padDecimalZeros.tsx +32 -0
  50. package/src/helpers/padZerosLeft.tsx +21 -0
  51. package/src/helpers/roundToNumDecimals.tsx +13 -0
  52. package/src/helpers/sum.tsx +16 -0
  53. package/src/helpers/waitMs.tsx +12 -0
  54. package/src/types/Variant.tsx +16 -0
  55. package/tsconfig.json +24 -0
  56. package/index.js +0 -1
  57. package/lib/Bar.js +0 -169
  58. package/lib/Donut.js +0 -145
  59. package/lib/DownloadButton.js +0 -81
  60. package/lib/Histogram.js +0 -193
  61. package/lib/Scatter.js +0 -162
  62. package/lib/StackedBar.js +0 -243
  63. package/lib/common/chart/Holder/index.js +0 -182
  64. package/lib/common/chart/Holder/style.css +0 -41
  65. package/lib/common/chart/colors.js +0 -12
  66. package/lib/common/csvToString.js +0 -23
  67. package/lib/common/isFloat.js +0 -14
  68. package/lib/common/isInteger.js +0 -24
  69. package/lib/common/math.js +0 -21
  70. package/lib/common/validators.js +0 -18
  71. package/lib/glyph/Adjust.js +0 -13
  72. package/lib/glyph/Angle.js +0 -44
  73. package/lib/glyph/Archive.js +0 -13
  74. package/lib/glyph/Arrow.js +0 -49
  75. package/lib/glyph/ArrowsHorizontal.js +0 -13
  76. package/lib/glyph/ArrowsVertical.js +0 -13
  77. package/lib/glyph/Award.js +0 -13
  78. package/lib/glyph/Ban.js +0 -13
  79. package/lib/glyph/Barcode.js +0 -13
  80. package/lib/glyph/Bed.js +0 -13
  81. package/lib/glyph/Bell.js +0 -35
  82. package/lib/glyph/Bolt.js +0 -13
  83. package/lib/glyph/Bookmark.js +0 -37
  84. package/lib/glyph/Bug.js +0 -13
  85. package/lib/glyph/Calendar.js +0 -13
  86. package/lib/glyph/Check.js +0 -36
  87. package/lib/glyph/Checkbox.js +0 -40
  88. package/lib/glyph/Chevron.js +0 -63
  89. package/lib/glyph/Circle.js +0 -15
  90. package/lib/glyph/Cog.js +0 -13
  91. package/lib/glyph/DoubleAngle.js +0 -45
  92. package/lib/glyph/Download.js +0 -13
  93. package/lib/glyph/Ellipsis.js +0 -36
  94. package/lib/glyph/Envelope.js +0 -13
  95. package/lib/glyph/File.js +0 -37
  96. package/lib/glyph/IdCard.js +0 -13
  97. package/lib/glyph/Menu.js +0 -13
  98. package/lib/glyph/Minus.js +0 -13
  99. package/lib/glyph/Move.js +0 -13
  100. package/lib/glyph/Plus.js +0 -13
  101. package/lib/glyph/Square.js +0 -47
  102. package/lib/glyph/Teacher.js +0 -13
  103. package/lib/glyph/TextAlign.js +0 -53
  104. package/lib/glyph/Times.js +0 -36
  105. package/lib/glyph/WarningTriangle.js +0 -13
  106. package/lib/index.js +0 -1
  107. package/src-old/common/csvToString.js +0 -5
  108. package/src-old/common/isFloat.js +0 -3
  109. package/src-old/common/isInteger.js +0 -14
  110. package/src-old/common/math.js +0 -16
  111. package/src-old/common/validators.js +0 -14
  112. package/src-old/components/Alert.js +0 -79
  113. package/src-old/components/Button.js +0 -64
  114. package/src-old/components/CSV/autoMatch.js +0 -174
  115. package/src-old/components/CSV/getNumCols.js +0 -15
  116. package/src-old/components/CSV/index.js +0 -743
  117. package/src-old/components/Card.js +0 -64
  118. package/src-old/components/Chart/Bar.js +0 -169
  119. package/src-old/components/Chart/Donut.js +0 -160
  120. package/src-old/components/Chart/Histogram.js +0 -189
  121. package/src-old/components/Chart/Scatter.js +0 -162
  122. package/src-old/components/Chart/colors.js +0 -20
  123. package/src-old/components/Checkbox/index.js +0 -106
  124. package/src-old/components/Checkbox/style.css +0 -11
  125. package/src-old/components/DatePicker.js +0 -59
  126. package/src-old/components/DownloadButton.js +0 -72
  127. package/src-old/components/Dropdown.js +0 -120
  128. package/src-old/components/Layout/LeftAddon.js +0 -63
  129. package/src-old/components/Layout/RightAddon.js +0 -64
  130. package/src-old/components/Layout/TwoCol.js +0 -67
  131. package/src-old/components/Modal.js +0 -161
  132. package/src-old/components/PhotoRoster.js +0 -152
  133. package/src-old/components/Pills.js +0 -117
  134. package/src-old/components/Radio.js +0 -94
  135. package/src-old/components/Splash/Error.js +0 -62
  136. package/src-old/components/Splash/Load/index.js +0 -32
  137. package/src-old/components/Splash/Load/style.css +0 -51
  138. package/src-old/components/Stat/General.js +0 -252
  139. package/src-old/components/Stat/helpers/calcAverage.js +0 -20
  140. package/src-old/components/Stat/helpers/calcExtremes.js +0 -27
  141. package/src-old/components/Stat/helpers/calcMedian.js +0 -32
  142. package/src-old/components/Stat/helpers/calcStdDev.js +0 -30
  143. package/src-old/components/Stat/helpers/calcSum.js +0 -8
  144. package/src-old/components/UserProfile/index.js +0 -151
  145. package/src-old/components/UserProfile/style.css +0 -33
  146. package/src-old/components/Well.js +0 -28
  147. package/src-old/components/Wizard/Question/CSV.js +0 -307
  148. package/src-old/components/Wizard/Question/Chooser/Assignment.js +0 -108
  149. package/src-old/components/Wizard/Question/Chooser/Course.js +0 -214
  150. package/src-old/components/Wizard/Question/Chooser/helpers/divideIntoSections.js +0 -16
  151. package/src-old/components/Wizard/Question/Chooser/helpers/genGetItemsPromise.js +0 -20
  152. package/src-old/components/Wizard/Question/Chooser/helpers/preprocessSections.js +0 -36
  153. package/src-old/components/Wizard/Question/Chooser/index.js +0 -306
  154. package/src-old/components/Wizard/Question/Form/Field/CheckableItem.js +0 -155
  155. package/src-old/components/Wizard/Question/Form/Field/Input.js +0 -149
  156. package/src-old/components/Wizard/Question/Form/Field/NumberItem.js +0 -374
  157. package/src-old/components/Wizard/Question/Form/Field/index.js +0 -34
  158. package/src-old/components/Wizard/Question/Form/Field/readme.md +0 -7
  159. package/src-old/components/Wizard/Question/Form/index.js +0 -175
  160. package/src-old/components/Wizard/Question/Form/style.css +0 -3
  161. package/src-old/components/Wizard/Question/OneButton.js +0 -80
  162. package/src-old/components/Wizard/Question/index.js +0 -46
  163. package/src-old/components/Wizard/Question/readme.md +0 -10
  164. package/src-old/components/Wizard/QuestionGroup/AnswerAll.js +0 -126
  165. package/src-old/components/Wizard/QuestionGroup/AnswerAny.js +0 -60
  166. package/src-old/components/Wizard/index.js +0 -233
  167. package/src-old/components/Wizard/style.css +0 -21
  168. package/src-old/glyphs/Adjust.js +0 -13
  169. package/src-old/glyphs/Angle.js +0 -57
  170. package/src-old/glyphs/Archive.js +0 -13
  171. package/src-old/glyphs/Arrow.js +0 -85
  172. package/src-old/glyphs/ArrowsHorizontal.js +0 -13
  173. package/src-old/glyphs/ArrowsVertical.js +0 -13
  174. package/src-old/glyphs/Award.js +0 -13
  175. package/src-old/glyphs/Ban.js +0 -13
  176. package/src-old/glyphs/Barcode.js +0 -13
  177. package/src-old/glyphs/Bed.js +0 -13
  178. package/src-old/glyphs/Bell.js +0 -34
  179. package/src-old/glyphs/Bolt.js +0 -13
  180. package/src-old/glyphs/Bookmark.js +0 -36
  181. package/src-old/glyphs/Bug.js +0 -13
  182. package/src-old/glyphs/Calendar.js +0 -13
  183. package/src-old/glyphs/Check.js +0 -34
  184. package/src-old/glyphs/Checkbox.js +0 -42
  185. package/src-old/glyphs/Chevron.js +0 -88
  186. package/src-old/glyphs/Circle.js +0 -16
  187. package/src-old/glyphs/Cog.js +0 -13
  188. package/src-old/glyphs/DoubleAngle.js +0 -58
  189. package/src-old/glyphs/Download.js +0 -13
  190. package/src-old/glyphs/Ellipsis.js +0 -35
  191. package/src-old/glyphs/Envelope.js +0 -13
  192. package/src-old/glyphs/File.js +0 -40
  193. package/src-old/glyphs/IdCard.js +0 -13
  194. package/src-old/glyphs/Menu.js +0 -13
  195. package/src-old/glyphs/Minus.js +0 -13
  196. package/src-old/glyphs/Move.js +0 -13
  197. package/src-old/glyphs/Plus.js +0 -13
  198. package/src-old/glyphs/Square.js +0 -48
  199. package/src-old/glyphs/Teacher.js +0 -13
  200. package/src-old/glyphs/TextAlign.js +0 -58
  201. package/src-old/glyphs/Times.js +0 -34
  202. package/src-old/glyphs/WarningTriangle.js +0 -13
  203. package/src-old/index.js +0 -1
package/lib/Scatter.js DELETED
@@ -1,162 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import rechart components
5
- import { ResponsiveContainer, ScatterChart, Scatter as ScatterLib, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
6
-
7
- // Import helpers
8
- import csvToString from './common/csvToString';
9
-
10
- // Import other components
11
- import Holder from './common/chart/Holder';
12
-
13
- // Import default colors
14
- import colors from './common/chart/colors';
15
-
16
- /* Scatter Chart Component */
17
- class Scatter extends Component {
18
- render() {
19
- // Deconstruct props (see propTypes below for detailed information)
20
- const {
21
- title,
22
- color,
23
- width,
24
- height,
25
- xLabel,
26
- xUnit,
27
- yLabel,
28
- yUnit,
29
- data,
30
- noTooltipOnHover,
31
- noDownload,
32
- showLegend,
33
- seriesName
34
- } = this.props;
35
-
36
- // Generate csv contents if we have a download button
37
- let csvContents;
38
- if (!noDownload) {
39
- // Create x and y column labels dynamically
40
- const xField = `${xLabel}${xUnit ? ' (' + xUnit + ')' : ''}`;
41
- const yField = `${yLabel}${yUnit ? ' (' + yUnit + ')' : ''}`;
42
- // Create the csv content object
43
- const csv = {
44
- fields: [xField, yField],
45
- data: data.map(datum => {
46
- return [datum.x, datum.y];
47
- })
48
- };
49
- // Create the csv string
50
- csvContents = csvToString(csv);
51
- }
52
-
53
- // Render the component
54
- return React.createElement(
55
- Holder,
56
- {
57
- title: title,
58
- xLabel: xLabel,
59
- xUnit: xUnit,
60
- yLabel: yLabel,
61
- yUnit: yUnit,
62
- width: width,
63
- height: height,
64
- csvContents: csvContents
65
- },
66
- React.createElement(
67
- ResponsiveContainer,
68
- {
69
- width: '100%',
70
- height: '100%'
71
- },
72
- React.createElement(
73
- ScatterChart,
74
- null,
75
- React.createElement(CartesianGrid, null),
76
- React.createElement(YAxis, {
77
- dataKey: 'y',
78
- type: 'number',
79
- name: yLabel
80
- }),
81
- React.createElement(XAxis, {
82
- dataKey: 'x',
83
- type: 'number',
84
- name: xLabel
85
- }),
86
- !noTooltipOnHover && React.createElement(Tooltip, {
87
- cursor: {
88
- strokeDasharray: '3 3'
89
- }
90
- }),
91
- showLegend && React.createElement(Legend, null),
92
- React.createElement(ScatterLib, {
93
- name: seriesName,
94
- data: data,
95
- fill: color
96
- })
97
- )
98
- )
99
- );
100
- }
101
- }
102
-
103
- Scatter.propTypes = {
104
- // Title of the chart
105
- title: PropTypes.string,
106
- // CSS color (#123456 or 'white') for the points
107
- color: PropTypes.string,
108
- // Width ('100%' or 50)
109
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
110
- // Height ('100%' or 50)
111
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
112
- // Label for the x axis
113
- xLabel: PropTypes.string,
114
- // Unit for the x axis
115
- xUnit: PropTypes.string,
116
- // Label for the y axis
117
- yLabel: PropTypes.string,
118
- // Unit for the y axis
119
- yUnit: PropTypes.string,
120
- // Array of data objects
121
- data: PropTypes.arrayOf(PropTypes.shape({
122
- x: PropTypes.number,
123
- y: PropTypes.number
124
- })).isRequired,
125
- // If true, no tooltip is shown when hovering over a point
126
- noTooltipOnHover: PropTypes.bool,
127
- // If true, no download button is shown
128
- noDownload: PropTypes.bool,
129
- // Name of the series (included and required for legend)
130
- seriesName: PropTypes.string,
131
- // If true, legend is included
132
- showLegend: PropTypes.bool
133
- };
134
-
135
- Scatter.defaultProps = {
136
- // Chart has no title by default
137
- title: null,
138
- // Scatter dots are neutral blue by default
139
- color: colors.defaultBlue,
140
- // Chart takes up full width of parent by default
141
- width: '100%',
142
- // Chart's height is 500px by default
143
- height: '500px',
144
- // Label for x axis is 'x-axis' by default
145
- xLabel: 'x-axis',
146
- // X axis has no unit by default
147
- xUnit: null,
148
- // Label for y axis is 'y-axis' by default
149
- yLabel: 'y-axis',
150
- // Y axis has no unit by default
151
- yUnit: null,
152
- // Scatter series is 'Chart' by default (for the legend)
153
- seriesName: 'Chart',
154
- // Tooltips are displayed by default
155
- noTooltipOnHover: false,
156
- // Download button is added by default
157
- noDownload: false,
158
- // No legend is included by default
159
- showLegend: false
160
- };
161
-
162
- export default Scatter;
package/lib/StackedBar.js DELETED
@@ -1,243 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import chart components
5
- import { ResponsiveContainer, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
6
-
7
- // Import other components
8
- import Holder from './common/chart/Holder';
9
-
10
- // Import default colors
11
- import colors from './common/chart/colors';
12
-
13
- // Import helpers
14
- import csvToString from './common/csvToString';
15
-
16
- /* Stacked Bar Chart Component */
17
- class StackedBar extends Component {
18
- render() {
19
- // Deconstruct props (see propTypes below for detailed information)
20
- const {
21
- title,
22
- width,
23
- height,
24
- valueColors,
25
- nameLabel,
26
- nameUnit,
27
- valuesLabel,
28
- valuesUnit,
29
- valueLabels,
30
- valueUnits,
31
- data,
32
- horizontal,
33
- noTooltipOnHover,
34
- noDownload,
35
- showLegend
36
- } = this.props;
37
-
38
- // Pre-process the values
39
- // Collect all the value names
40
- let valueNames = {}; // valueName => true
41
- data.forEach(datum => {
42
- if (datum.values) {
43
- Object.keys(datum.values).forEach(valueName => {
44
- valueNames[valueName] = true;
45
- });
46
- }
47
- });
48
- valueNames = Object.keys(valueNames);
49
- // Put together value objects
50
- const valueObjects = {}; // valueName => { valueName, label, unit, color }
51
- let nextAssortmentColorIndex = 0;
52
- valueNames.forEach(valueName => {
53
- // Get the color
54
- let color;
55
- if (colors === 'assortment' || !valueColors[valueName]) {
56
- color = colors.assortment[nextAssortmentColorIndex % colors.assortment.length];
57
- nextAssortmentColorIndex += 1;
58
- } else {
59
- color = valueColors[valueName];
60
- }
61
-
62
- // Create a value object
63
- const valueObject = {
64
- valueName,
65
- color,
66
- label: valueLabels[valueName] || valueName,
67
- unit: valueUnits[valueName] || null
68
- };
69
-
70
- // Save the value object
71
- valueObjects[valueName] = valueObject;
72
- });
73
-
74
- // Pre-process the data
75
- const newData = []; // Array of { name, valueName: value, ...}
76
- data.forEach(datum => {
77
- const newDatum = {
78
- name: datum.name
79
- };
80
-
81
- // Add all values, set the number to zero if it wasn't defined
82
- valueNames.forEach(valueName => {
83
- newDatum[valueName] = datum.value[valueName] || 0;
84
- });
85
-
86
- // Save to newData
87
- newData.push(newDatum);
88
- });
89
-
90
- // Generate csv contents if they weren't included
91
- let { csvContents } = this.props;
92
- if (!noDownload && !csvContents) {
93
- const fields = [];
94
-
95
- // Create the name column using the label and unit (if it's included)
96
- fields.push(`${nameLabel}${nameUnit ? ' (' + nameUnit + ')' : ''}`);
97
-
98
- // Create the value columns using the label and unit (if it's included)
99
- valueNames.forEach(valueName => {
100
- const valueObject = valueObjects[valueName];
101
- fields.push(`${valueObject.label}${valueObject.unit ? ' (' + valueObject.unit + ')' : ''}`);
102
- });
103
-
104
- // Build the csv data object
105
- const csv = {
106
- fields,
107
- data: newData.map(datum => {
108
- return valueNames.map(valueName => {
109
- return datum[valueName];
110
- });
111
- })
112
- };
113
-
114
- // Turn the csv object into a string
115
- csvContents = csvToString(csv);
116
- }
117
-
118
- // Create the bars
119
- const bars = valueNames.map(valueName => {
120
- return React.createElement(Bar, {
121
- dataKey: valueName,
122
- stackId: 'a',
123
- fill: valueObjects[valueName].color
124
- });
125
- });
126
-
127
- // Render the component
128
- return React.createElement(
129
- Holder,
130
- {
131
- title: title,
132
- width: width,
133
- height: height,
134
- xLabel: horizontal ? valuesLabel : nameLabel,
135
- xUnit: horizontal ? valuesUnit : nameUnit,
136
- yLabel: horizontal ? nameLabel : valuesLabel,
137
- yUnit: horizontal ? nameUnit : valuesUnit,
138
- csvContents: csvContents
139
- },
140
- React.createElement(
141
- ResponsiveContainer,
142
- {
143
- width: '100%',
144
- height: '100%'
145
- },
146
- React.createElement(
147
- BarChart,
148
- {
149
- data: newData,
150
- layout: horizontal ? 'vertical' : 'horizontal'
151
- },
152
- React.createElement(CartesianGrid, { strokeDasharray: '3 3' }),
153
- React.createElement(XAxis, {
154
- type: horizontal ? 'number' : 'category',
155
- dataKey: horizontal ? null : 'name'
156
- }),
157
- React.createElement(YAxis, {
158
- type: horizontal ? 'category' : 'number',
159
- dataKey: horizontal ? 'name' : null
160
- }),
161
- !noTooltipOnHover && React.createElement(Tooltip, null),
162
- showLegend && React.createElement(Legend, null),
163
- bars
164
- )
165
- )
166
- );
167
- }
168
- }
169
-
170
- StackedBar.propTypes = {
171
- // Title of the chart
172
- title: PropTypes.string,
173
- // Default CSS colors (#123456 or 'white') for each bar (can be overridden)
174
- valueColors: PropTypes.objectOf(PropTypes.string),
175
- // Width ('100%' or 50)
176
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
177
- // Height ('100%' or 50)
178
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
179
- // Label for the name axis
180
- nameLabel: PropTypes.string,
181
- // Unit for the name axis
182
- nameUnit: PropTypes.string,
183
- // The label for the stacked bar axis
184
- valuesLabel: PropTypes.string,
185
- // The unit for the stcked bar axis
186
- valuesUnit: PropTypes.string,
187
- // Labels for the values
188
- valueLabels: PropTypes.objectOf(PropTypes.string),
189
- // Units for the values
190
- valueUnits: PropTypes.objectOf(PropTypes.string),
191
- // The data/bars
192
- data: PropTypes.arrayOf(PropTypes.shape({
193
- // Name of the bar
194
- name: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
195
- // Values of each bar
196
- values: PropTypes.object
197
- })).isRequired,
198
- // If true, bar chart is a horizontal bar chart
199
- horizontal: PropTypes.bool,
200
- // If true, no tooltip is shown on hover
201
- noTooltipOnHover: PropTypes.bool,
202
- // If true, legend is included
203
- showLegend: PropTypes.bool,
204
- // If true, no download button is shown
205
- noDownload: PropTypes.bool,
206
- // The contents of the csv file to download (auto-generated if not included)
207
- csvContents: PropTypes.string
208
- };
209
-
210
- StackedBar.defaultProps = {
211
- // No title for chart by default
212
- title: null,
213
- // By default, we use an assortment of colors, one for each value
214
- valueColors: 'assorted',
215
- // Chart takes up whole parent width by default
216
- width: '100%',
217
- // Chart is 500 pixels tall by default
218
- height: '500px',
219
- // Name axis is labeled 'Name' by default
220
- nameLabel: 'Name',
221
- // Name axis has no unit by default
222
- nameUnit: null,
223
- // The stacked bar axis is labeled 'Value' by default
224
- valuesLabel: 'Value',
225
- // The stacked bar axis has no unit by default
226
- valuesUnit: null,
227
- // Values are labeled by their property names by default
228
- valueLabels: {},
229
- // Values have no units by default
230
- valueUnits: {},
231
- // The bar chart is a vertical bar chart by default
232
- horizontal: false,
233
- // Tooltips are displayed by defaults
234
- noTooltipOnHover: false,
235
- // No legend is shown by default
236
- showLegend: false,
237
- // A download button is added by default
238
- noDownload: false,
239
- // We auto-generate the csv contents by default
240
- csvContents: null
241
- };
242
-
243
- export default StackedBar;
@@ -1,182 +0,0 @@
1
- import React, { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- // Import other components
5
- import DownloadButton from '../../../DownloadButton';
6
-
7
- // Import custom styles
8
- import './style.css';
9
-
10
- /* Holder Component */
11
- class Holder extends Component {
12
- render() {
13
- // Deconstruct props (see propTypes below for detailed information)
14
- const {
15
- title,
16
- xLabel,
17
- xUnit,
18
- yLabel,
19
- yUnit,
20
- width,
21
- height,
22
- csvContents,
23
- children
24
- } = this.props;
25
-
26
- // Calculate dimensions of the holder
27
- // > Chart height depends on if the title is included
28
- const chartHeight = `calc(${height}${title ? ' - 2.5em' : ''}${xLabel ? ' - 1.5em' : ''})`;
29
- // > Chart width depends on if there is a y axis label
30
- const chartWidth = `calc(${width}${yLabel ? ' - 1.5em' : ''})`;
31
-
32
- // The many parts of this component look like this:
33
- // |""""""""""""""""""""""""""""""""""""""""""|
34
- // | Chart title [Download] | <- title content
35
- // """"""""""""""""""""""""""""""""""""""""""""
36
- // |"""""|""""""""""""""""""""""""""""""""""""|
37
- // | Y | |
38
- // | L | |
39
- // | A | |
40
- // | B | Chart Here | <- top content
41
- // | E | |
42
- // | L | |
43
- // | | |
44
- // """"""""""""""""""""""""""""""""""""""""""""
45
- // |""""""""""""""""""""""""""""""""""""""""""|
46
- // | X LABEL | <- bottom content
47
- // """"""""""""""""""""""""""""""""""""""""""""
48
-
49
- // Create the title content (if there's a tite)
50
- const titleContent = title ? React.createElement(
51
- 'div',
52
- {
53
- style: {
54
- height: '2.5em'
55
- }
56
- },
57
- React.createElement(
58
- 'h4',
59
- { className: 'text-center' },
60
- title,
61
- csvContents && React.createElement(DownloadButton, {
62
- text: 'CSV',
63
- filename: `${title}.csv`,
64
- contents: csvContents,
65
- marginLeft: '5px'
66
- })
67
- )
68
- ) : null;
69
-
70
- // Create the top content
71
- // (includes the y-axis label and the chart, side by side)
72
- const topContent = React.createElement(
73
- 'div',
74
- null,
75
- yLabel && React.createElement(
76
- 'div',
77
- {
78
- className: 'y-label-container',
79
- style: {
80
- height: chartHeight
81
- }
82
- },
83
- React.createElement(
84
- 'div',
85
- {
86
- style: {
87
- width: chartHeight
88
- },
89
- className: 'y-label-text label-text'
90
- },
91
- yLabel,
92
- yUnit && React.createElement(
93
- 'span',
94
- { className: 'unit' },
95
- '(',
96
- yUnit,
97
- ')'
98
- )
99
- )
100
- ),
101
- React.createElement(
102
- 'div',
103
- {
104
- className: 'd-inline-block',
105
- style: {
106
- width: chartWidth,
107
- height: chartHeight
108
- }
109
- },
110
- children
111
- )
112
- );
113
-
114
- // Create the bottom if there's an x label
115
- // (includes the x label below the chart)
116
- const bottomContent = xLabel ? React.createElement(
117
- 'div',
118
- { className: 'x-label-text label-text' },
119
- xLabel,
120
- xUnit && React.createElement(
121
- 'span',
122
- { className: 'unit' },
123
- '(',
124
- xUnit,
125
- ')'
126
- )
127
- ) : null;
128
-
129
- // Put all the pieces together into one component
130
- return React.createElement(
131
- 'div',
132
- { className: 'mb-4' },
133
- React.createElement(
134
- 'div',
135
- {
136
- className: 'outer-container',
137
- style: {
138
- width,
139
- height
140
- }
141
- },
142
- titleContent,
143
- topContent,
144
- bottomContent
145
- )
146
- );
147
- }
148
- }
149
-
150
- Holder.propTypes = {
151
- // Title of the chart
152
- title: PropTypes.string,
153
- // Label of the x axis
154
- xLabel: PropTypes.string,
155
- // Units on the x axis
156
- xUnit: PropTypes.string,
157
- // Label of the y axis
158
- yLabel: PropTypes.string,
159
- // Units on the y axis
160
- yUnit: PropTypes.string,
161
- // Width of the chart (does not include the title)
162
- width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
163
- // Height of the chart (does not include the title)
164
- height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
165
- // The chart object (should be set to fill 100% width an height)
166
- children: PropTypes.node.isRequired,
167
- // File contents to download
168
- csvContents: PropTypes.string
169
- };
170
-
171
- Holder.defaultProps = {
172
- title: null,
173
- xLabel: null,
174
- xUnit: null,
175
- yLabel: null,
176
- yUnit: null,
177
- width: '100%',
178
- height: '500px',
179
- csvContents: null
180
- };
181
-
182
- export default Holder;
@@ -1,41 +0,0 @@
1
- /* the outermost container of the holder */
2
- .outer-container {
3
- display: inline-block;
4
- vertical-align: middle;
5
- }
6
-
7
- /* container for the y label - automatically moves to the left of the chart */
8
- .y-label-container {
9
- display: inline-block;
10
- width: 1.5em;
11
- float: left;
12
- }
13
-
14
- /* text of the y label - text is centered, vertical, and rotated */
15
- .y-label-text {
16
- display: inline-block;
17
- height: 1.5em;
18
- float: left;
19
- transform: rotate(90deg);
20
- transform-origin: 0.75em;
21
- text-align: center;
22
- }
23
-
24
- /* text of the x label - text is centered */
25
- .x-label-text {
26
- height: 1.5em;
27
- text-align: center;
28
- }
29
-
30
- /* styles shared between both x and y labels - bold, slightly larger text*/
31
- .label-text {
32
- font-size: 1.1em;
33
- font-weight: bold;
34
- }
35
-
36
- /* axis unit style */
37
- .unit {
38
- margin-left: 5px;
39
- font-style: italic;
40
- font-weight: normal;
41
- }
@@ -1,12 +0,0 @@
1
- /* Default colors for use in charts, etc */
2
- export default {
3
- // A pretty neutral blue to use as a default color
4
- defaultBlue: '#419bf7',
5
-
6
- // A simple assortment of 14 colors
7
- assortment: [
8
- // First 10:
9
- '#ec4f6a', '#f19542', '#f6c353', '#61cbcc', '#419bf7', '#005392', '#7d5297', '#d261ab', '#7edfcf', '#5eac88',
10
- // Last 4:
11
- '#f4ce63', '#929000', '#5e5e5e', '#008e00']
12
- };
@@ -1,23 +0,0 @@
1
- import CSVParser from 'papaparse';
2
-
3
- /**
4
- * Function for turning a csv object into a csv string
5
- * @param {string[]} [csv.fields] - an array of field names. These will be used
6
- * generate the header row of the csv
7
- * @param {string[][]} [csv.data] - an array of csv rows, where each row is an
8
- * array of strings that correspond to the cells of the row
9
- * @return {string} the csv file contents
10
- */
11
- export default (csv => {
12
- return CSVParser.unparse(csv);
13
- });
14
-
15
- // Example:
16
- // const fields = ['Name', 'Age'];
17
- // const data = [['Divardo', '19'], ['Calicci', '22']];
18
- // const csv = { fields, data}
19
- //
20
- // Calling csvToString(csv) results in the following csv file:
21
- // Name, Age
22
- // Divardo, 19
23
- // Calicci, 22
@@ -1,14 +0,0 @@
1
- /**
2
- * Returns true if a string is a float (not an integer)
3
- * @param {string} str - the string to check
4
- * @return {boolean} whether or not the string represents a float
5
- */
6
- export default (str => {
7
- const match = String(str).match(/^-?\d*(\.\d+)?$/);
8
- // If no matches at all, this is not a float
9
- if (!match || match.length < 2) {
10
- return false;
11
- }
12
- // We found a match. Make sure it's a float
13
- return !!match[1];
14
- });