@@ -1057,7 +1057,8 @@ type BarChartSeries = {
1057
1057
horizontal :: Boolean ,
1058
1058
annotations :: RawArray <RawArray <Option <String >>>,
1059
1059
intervals :: RawArray <RawArray <RawArray <Number >>>,
1060
- default-interval-color :: Option <I . Color >
1060
+ default-interval-color :: Option <I . Color >,
1061
+ dot-chart :: Boolean ,
1061
1062
}
1062
1063
1063
1064
default-bar-chart-series = {
@@ -1067,7 +1068,8 @@ default-bar-chart-series = {
1067
1068
pointer-color: none,
1068
1069
axisdata: none,
1069
1070
horizontal: false ,
1070
- default-interval-color: none
1071
+ default-interval-color: none,
1072
+ dot-chart: false ,
1071
1073
}
1072
1074
1073
1075
type MultiBarChartSeries = {
@@ -1127,6 +1129,7 @@ type LinePlotSeries = {
1127
1129
pointshapeSides :: NumInteger ,
1128
1130
pointshapeDent :: Number ,
1129
1131
pointshapeRotation :: Number ,
1132
+ dot-chart :: Boolean ,
1130
1133
}
1131
1134
1132
1135
default-line-plot-series = {
@@ -1146,6 +1149,7 @@ default-line-plot-series = {
1146
1149
pointshapeSides: 5 ,
1147
1150
pointshapeDent: 0.5 ,
1148
1151
pointshapeRotation: 0 ,
1152
+ dot-chart: false ,
1149
1153
}
1150
1154
1151
1155
type ScatterPlotSeries = {
@@ -1162,6 +1166,7 @@ type ScatterPlotSeries = {
1162
1166
pointshapeSides :: NumInteger ,
1163
1167
pointshapeDent :: Number ,
1164
1168
pointshapeRotation :: Number ,
1169
+ dot-chart :: Boolean ,
1165
1170
}
1166
1171
1167
1172
default-scatter-plot-series = {
@@ -1177,6 +1182,7 @@ default-scatter-plot-series = {
1177
1182
trendlineWidth: 3 ,
1178
1183
trendlineOpacity: 0.3 ,
1179
1184
trendlineDegree: 3 ,
1185
+ dot-chart: false
1180
1186
}
1181
1187
1182
1188
type IntervalChartSeries = {
@@ -1191,9 +1197,6 @@ type IntervalChartSeries = {
1191
1197
style :: String ,
1192
1198
horizontal :: Boolean ,
1193
1199
default-interval-color :: Option <I . Color >,
1194
- #
1195
- bothys :: List <Posn >,
1196
- ps :: List <Posn >,
1197
1200
legend :: String ,
1198
1201
trendlineType :: Option <String >,
1199
1202
trendlineColor :: Option <I . Color >,
@@ -1207,6 +1210,9 @@ type IntervalChartSeries = {
1207
1210
pointshapeSides :: NumInteger ,
1208
1211
pointshapeDent :: Number ,
1209
1212
pointshapeRotation :: Number ,
1213
+ bothys :: List <Posn >,
1214
+ ps :: List <Posn >,
1215
+ dot-chart :: Boolean ,
1210
1216
}
1211
1217
1212
1218
default-interval-chart-series = {
@@ -1230,6 +1236,7 @@ default-interval-chart-series = {
1230
1236
pointshapeSides: 5 ,
1231
1237
pointshapeDent: 0.5 ,
1232
1238
pointshapeRotation: 0 ,
1239
+ dot-chart: false ,
1233
1240
}
1234
1241
1235
1242
type FunctionPlotSeries = {
@@ -1917,6 +1924,92 @@ fun bar-chart-from-list(labels :: P.LoS, values :: P.LoN) -> DataSeries block:
1917
1924
data-series. make-axis( max-positive-height, max-negative-height)
1918
1925
end
1919
1926
1927
+ fun num-dot-chart-from-list( x-values :: P . LoN ) -> DataSeries block:
1928
+ doc: ```
1929
+ Consume a (possibly repeating, unordered) list of numbers
1930
+ and construct a dot chart
1931
+ ```
1932
+ x-values. each( check-num)
1933
+ when x-values. length() == 0 :
1934
+ raise( "num-dot-chart: can't have empty data" )
1935
+ end
1936
+ scatter-plot-ys = x-values. map( lam ( _) : 0 end )
1937
+ default-scatter-plot-series. {
1938
+ ps: map4( { ( x, y, z, img) : [ raw-array: x, y, z, img]} ,
1939
+ x-values, scatter-plot-ys,
1940
+ x-values. map( { ( _) : '' } ) , x-values. map( { ( _) : false } )) ,
1941
+ dot-chart: true
1942
+ } ^ scatter-plot-series
1943
+ end
1944
+
1945
+ fun labeled-num-dot-chart-from-list( labels :: P . LoS , x-values :: P . LoN ) -> DataSeries block:
1946
+ doc: ```
1947
+ Consume unordered, possibly-repeating lists of labels and numbers,
1948
+ and construct a dot chart
1949
+ ```
1950
+ x-values. each( check-num)
1951
+ when x-values. length() == 0 :
1952
+ raise( "num-dot-chart: can't have empty data" )
1953
+ end
1954
+ labels. each( check-string)
1955
+ when labels. length() <> x-values. length() :
1956
+ raise( "num-dot-chart: the lists of numbers and labels must have the same length" )
1957
+ end
1958
+ scatter-plot-ys = x-values. map( lam ( _) : 0 end )
1959
+ default-scatter-plot-series. {
1960
+ ps: map4( { ( x, y, z, img) : [ raw-array: x, y, z, img]} ,
1961
+ x-values, scatter-plot-ys, labels,
1962
+ x-values. map( { ( _) : false } )) ,
1963
+ dot-chart: true
1964
+ } ^ scatter-plot-series
1965
+ end
1966
+
1967
+ fun dot-chart-from-list( input-labels :: P . LoS ) -> DataSeries block:
1968
+ doc: ```
1969
+ Consume a list of string-values and construct a dot chart
1970
+ ```
1971
+
1972
+ # Edge Case Error Checking
1973
+ when input-labels. length() == 0 :
1974
+ raise( "dot-chart: can't have empty data" )
1975
+ end
1976
+
1977
+ # Type Checking
1978
+ input-labels. each( check-string)
1979
+
1980
+ # Walk through the (sorted) values, creating lists of labels and counts
1981
+ unique-counts = foldl(
1982
+ lam ( acc, elt) :
1983
+ labels = acc. { 0 }
1984
+ counts = acc. { 1 }
1985
+ if labels. member( elt) :
1986
+ { labels; counts. set( 0 , counts. get( 0 ) + 1 ) }
1987
+ else :
1988
+ { link( elt, labels) ; link( 1 , counts) }
1989
+ end
1990
+ end ,
1991
+ {[ list: ] ; [ list: ]} ,
1992
+ input-labels. sort())
1993
+
1994
+ labels = unique-counts. { 0 }
1995
+ values = unique-counts. { 1 }
1996
+ rational-values = map( num-to-rational, values)
1997
+
1998
+ # set the vAxis values, and create the data series
1999
+ { max-positive-height; max-negative-height} = prep-axis( rational-values)
2000
+
2001
+ data-series = default-bar-chart-series. {
2002
+ tab: to-table2-n( labels, rational-values) ,
2003
+ dot-chart: true ,
2004
+ axis-top: max-positive-height,
2005
+ axis-bottom: max-negative-height,
2006
+ annotations: values. map( { ( _) : [ list: none]} ) ^ list-to-table2,
2007
+ intervals: values. map( { ( _) : [ list: [ raw-array: ]]} ) ^ list-to-table2,
2008
+ } ^ bar-chart-series
2009
+
2010
+ data-series. make-axis( max-positive-height, max-negative-height)
2011
+ end
2012
+
1920
2013
fun grouped-bar-chart-from-list(
1921
2014
labels :: P . LoS ,
1922
2015
value-lists :: P . LoLoN ,
@@ -2613,6 +2706,9 @@ from-list = {
2613
2706
exploding-pie-chart: exploding-pie-chart-from-list,
2614
2707
image-pie-chart: image-pie-chart-from-list,
2615
2708
bar-chart: bar-chart-from-list,
2709
+ dot-chart: dot-chart-from-list,
2710
+ num-dot-chart: num-dot-chart-from-list,
2711
+ labeled-num-dot-chart: labeled-num-dot-chart-from-list,
2616
2712
image-bar-chart: image-bar-chart-from-list,
2617
2713
grouped-bar-chart: grouped-bar-chart-from-list,
2618
2714
stacked-bar-chart: stacked-bar-chart-from-list,
0 commit comments