@@ -38,21 +38,17 @@ class FunnelGraph {
38
38
------
39
39
---#1----------------
40
40
#0-----------------
41
-
42
41
Main axis is the primary axis of the graph.
43
42
In a horizontal graph it's the X axis, and Y is the cross axis.
44
43
However we use the names "main" and "cross" axis,
45
44
because in a vertical graph the primary axis is the Y axis
46
45
and the cross axis is the X axis.
47
-
48
46
First step of drawing the funnel graph is getting the coordinates of points,
49
47
that are used when drawing the paths.
50
-
51
48
There are 4 paths in the example above: A, B, C and D.
52
49
Such funnel has 3 labels and 3 subLabels.
53
50
This means that the main axis has 4 points (number of labels + 1)
54
51
One the ASCII illustrated graph above, those points are illustrated with a # symbol.
55
-
56
52
*/
57
53
getMainAxisPoints ( ) {
58
54
const size = this . getDataSize ( ) ;
@@ -183,10 +179,7 @@ class FunnelGraph {
183
179
184
180
const percentageValue = document . createElement ( 'div' ) ;
185
181
percentageValue . setAttribute ( 'class' , 'label__percentage' ) ;
186
-
187
- if ( percentage !== 100 ) {
188
- percentageValue . textContent = `${ percentage . toString ( ) } %` ;
189
- }
182
+ percentageValue . textContent = `${ percentage . toString ( ) } %` ;
190
183
191
184
labelElement . appendChild ( value ) ;
192
185
labelElement . appendChild ( title ) ;
@@ -322,7 +315,7 @@ class FunnelGraph {
322
315
}
323
316
324
317
const max = Math . max ( ...values ) ;
325
- return values . map ( value => roundPoint ( value * 100 / max ) ) ;
318
+ return values . map ( value => value === 0 ? 0 : roundPoint ( value * 100 / max ) ) ;
326
319
}
327
320
328
321
applyGradient ( svg , path , colors , index ) {
@@ -663,4 +656,4 @@ class FunnelGraph {
663
656
}
664
657
}
665
658
666
- export default FunnelGraph ;
659
+ export default FunnelGraph ;
0 commit comments