@@ -343,7 +343,7 @@ labels-method = method(self, labels :: CL.LoS):
343343 when self. obj! ps. length() <> labels. length() :
344344 raise( ERR . message-exception( 'plot: xs and labels should have the same length' ))
345345 end
346- self. constr()( self. obj. { ps: map2( { ( arr , label) : raw-array-set ( arr, 2 , label) } , self. obj! ps, labels) } )
346+ self. constr()( self. obj. { ps: map2( { ( val , label) : val . { label : label} } , self. obj! ps, labels) } )
347347 end
348348end
349349
@@ -352,7 +352,7 @@ image-labels-method = method(self, images :: CL.LoI):
352352 when self. obj! ps. length() <> images. length() :
353353 raise( ERR . message-exception( 'plot: xs and images should have the same length' ))
354354 end
355- self. constr()( self. obj. { ps: map2( { ( arr , image) : raw-array-set ( arr, 3 , image) } , self. obj! ps, images) } )
355+ self. constr()( self. obj. { ps: map2( { ( val , image) : val . { image : some ( image) } } , self. obj! ps, images) } )
356356 end
357357end
358358
@@ -508,6 +508,10 @@ x-axis-method = method(self, x-axis :: String):
508508 self. constr()( self. obj. { x-axis: x-axis} )
509509end
510510
511+ x-axis-stagger-labels-method = method ( self, stagger :: Boolean ) :
512+ self. constr()( self. obj. { x-axis-stagger-labels: stagger} )
513+ end
514+
511515y-axis-method = method ( self, y-axis :: String ) :
512516 self. constr()( self. obj. { y-axis: y-axis} )
513517end
@@ -1241,18 +1245,21 @@ default-dot-plot-series = {
12411245
12421246type CategoricalDotPoint = {
12431247 label :: String ,
1244- count :: Number
1248+ category :: String ,
1249+ image :: Option <IM . Image >
12451250}
12461251
12471252type CategoricalDotPlotSeries = {
12481253 ps :: List <CategoricalDotPoint >,
12491254 color :: Option <IS . Color >,
1250- legend :: String
1255+ legend :: String ,
1256+ useImageSizes :: Boolean
12511257}
12521258
12531259default-categorical-dot-plot-series = {
12541260 color: none,
12551261 legend: '' ,
1262+ useImageSizes: true ,
12561263}
12571264
12581265type IntervalPoint = {
@@ -1355,6 +1362,7 @@ type BoxChartWindowObject = {
13551362 borderSize :: Number ,
13561363 borderColor :: Option <IS . Color >,
13571364 x-axis :: String ,
1365+ x-axis-stagger-labels :: Boolean ,
13581366 y-axis :: String ,
13591367 x-axis-type :: AxisType ,
13601368 y-axis-type :: AxisType ,
@@ -1366,6 +1374,7 @@ type BoxChartWindowObject = {
13661374default-box-plot-chart-window-object :: BoxChartWindowObject = default-chart-window-object. {
13671375 x-axis: '' ,
13681376 y-axis: '' ,
1377+ x-axis-stagger-labels: false ,
13691378 x-axis-type: at-linear,
13701379 y-axis-type: at-linear,
13711380 min: none,
@@ -1393,6 +1402,7 @@ type DotChartWindowObject = {
13931402 borderColor :: Option <IS . Color >,
13941403 render :: ( -> IM . Image ) ,
13951404 x-axis :: String ,
1405+ x-axis-stagger-labels :: Boolean ,
13961406 y-axis :: String ,
13971407 x-axis-type :: AxisType ,
13981408 y-axis-type :: AxisType ,
@@ -1402,6 +1412,7 @@ type DotChartWindowObject = {
14021412
14031413default-dot-chart-window-object :: DotChartWindowObject = default-chart-window-object. {
14041414 x-axis: '' ,
1415+ x-axis-stagger-labels: false ,
14051416 y-axis: '' ,
14061417 x-axis-type: at-linear,
14071418 y-axis-type: at-linear,
@@ -1418,6 +1429,7 @@ type BarChartWindowObject = {
14181429 borderColor :: Option <IS . Color >,
14191430 render :: ( -> IM . Image ) ,
14201431 x-axis :: String ,
1432+ x-axis-stagger-labels :: Boolean ,
14211433 y-axis :: String ,
14221434 x-axis-type :: AxisType ,
14231435 y-axis-type :: AxisType ,
@@ -1427,6 +1439,7 @@ type BarChartWindowObject = {
14271439
14281440default-bar-chart-window-object :: BarChartWindowObject = default-chart-window-object. {
14291441 x-axis: '' ,
1442+ x-axis-stagger-labels: false ,
14301443 y-axis: '' ,
14311444 x-axis-type: at-linear,
14321445 y-axis-type: at-linear,
@@ -1443,6 +1456,7 @@ type IntervalChartWindowObject = {
14431456 borderColor :: Option <IS . Color >,
14441457 render :: ( -> IM . Image ) ,
14451458 x-axis :: String ,
1459+ x-axis-stagger-labels :: Boolean ,
14461460 y-axis :: String ,
14471461 x-axis-type :: AxisType ,
14481462 y-axis-type :: AxisType ,
@@ -1452,6 +1466,7 @@ type IntervalChartWindowObject = {
14521466
14531467default-interval-chart-window-object :: IntervalChartWindowObject = default-chart-window-object. {
14541468 x-axis: '' ,
1469+ x-axis-stagger-labels: false ,
14551470 y-axis: '' ,
14561471 x-axis-type: at-linear,
14571472 y-axis-type: at-linear,
@@ -1468,6 +1483,7 @@ type HistogramChartWindowObject = {
14681483 borderColor :: Option <IS . Color >,
14691484 render :: ( -> IM . Image ) ,
14701485 x-axis :: String ,
1486+ x-axis-stagger-labels :: Boolean ,
14711487 y-axis :: String ,
14721488 x-axis-type :: AxisType ,
14731489 y-axis-type :: AxisType ,
@@ -1479,6 +1495,7 @@ type HistogramChartWindowObject = {
14791495default-histogram-chart-window-object :: HistogramChartWindowObject =
14801496 default-chart-window-object. {
14811497 x-axis: '' ,
1498+ x-axis-stagger-labels: false ,
14821499 y-axis: '' ,
14831500 x-axis-type: at-linear,
14841501 y-axis-type: at-linear,
@@ -1502,6 +1519,7 @@ type PlotChartWindowObject = {
15021519 minorGridlineColor :: Option <IS . Color >,
15031520 minorGridlineMinspacing :: Number ,
15041521 x-axis :: String ,
1522+ x-axis-stagger-labels :: Boolean ,
15051523 y-axis :: String ,
15061524 x-axis-type :: AxisType ,
15071525 y-axis-type :: AxisType ,
@@ -1515,6 +1533,7 @@ type PlotChartWindowObject = {
15151533
15161534default-plot-chart-window-object :: PlotChartWindowObject = default-chart-window-object. {
15171535 x-axis: '' ,
1536+ x-axis-stagger-labels: false ,
15181537 y-axis: '' ,
15191538 x-axis-type: at-linear,
15201539 y-axis-type: at-linear,
@@ -1606,6 +1625,11 @@ data DataSeries:
16061625 constr: { () : categorical-dot-plot-series} ,
16071626 color: color-method,
16081627 legend: legend-method,
1628+ labels: labels-method,
1629+ image-labels: image-labels-method,
1630+ method use-image-sizes( self, use-image-sizes :: Boolean ) :
1631+ self. constr()( self. obj. { useImageSizes: use-image-sizes} )
1632+ end ,
16091633 | function-plot-series( obj :: FunctionPlotSeries ) with:
16101634 is-single: false ,
16111635 constr: { () : function-plot-series} ,
@@ -1744,6 +1768,7 @@ data ChartWindow:
17441768 | dot-chart-window( obj :: DotChartWindowObject ) with:
17451769 constr: { () : dot-chart-window} ,
17461770 x-axis: x-axis-method,
1771+ x-axis-stagger-labels: x-axis-stagger-labels-method,
17471772 y-axis: y-axis-method,
17481773 x-min: x-min-method,
17491774 x-max: x-max-method,
@@ -1752,6 +1777,7 @@ data ChartWindow:
17521777 | box-plot-chart-window( obj :: BoxChartWindowObject ) with:
17531778 constr: { () : box-plot-chart-window} ,
17541779 x-axis: x-axis-method,
1780+ x-axis-stagger: x-axis-stagger-labels-method,
17551781 y-axis: y-axis-method,
17561782 x-axis-type: x-axis-type-method,
17571783 y-axis-type: y-axis-type-method,
@@ -1760,6 +1786,7 @@ data ChartWindow:
17601786 | bar-chart-window( obj :: BarChartWindowObject ) with:
17611787 constr: { () : bar-chart-window} ,
17621788 x-axis: x-axis-method,
1789+ x-axis-stagger: x-axis-stagger-labels-method,
17631790 y-axis: y-axis-method,
17641791 x-axis-type: x-axis-type-method,
17651792 y-axis-type: y-axis-type-method,
@@ -1768,6 +1795,7 @@ data ChartWindow:
17681795 | interval-chart-window( obj :: IntervalChartWindowObject ) with:
17691796 constr: { () : interval-chart-window} ,
17701797 x-axis: x-axis-method,
1798+ x-axis-stagger: x-axis-stagger-labels-method,
17711799 y-axis: y-axis-method,
17721800 x-axis-type: x-axis-type-method,
17731801 y-axis-type: y-axis-type-method,
@@ -1776,6 +1804,7 @@ data ChartWindow:
17761804 | histogram-chart-window( obj :: HistogramChartWindowObject ) with:
17771805 constr: { () : histogram-chart-window} ,
17781806 x-axis: x-axis-method,
1807+ x-axis-stagger: x-axis-stagger-labels-method,
17791808 y-axis: y-axis-method,
17801809 x-axis-type: x-axis-type-method,
17811810 y-axis-type: y-axis-type-method,
@@ -1791,6 +1820,7 @@ data ChartWindow:
17911820 # minor-gridlines-color: minor-gridlines-color-method,
17921821 # minor-gridlines-minspacing: minor-gridlines-min-spacing-method,
17931822 x-axis: x-axis-method,
1823+ x-axis-stagger: x-axis-stagger-labels-method,
17941824 y-axis: y-axis-method,
17951825 x-axis-type: x-axis-type-method,
17961826 y-axis-type: y-axis-type-method,
@@ -1943,12 +1973,6 @@ fun image-bar-chart-from-list(
19431973 Consume images, labels, a list of string, and values, a list of numbers
19441974 and construct a bar chart using images as bars
19451975 ```
1946-
1947- # Type Checking
1948- images. each( check-image)
1949- values. each( check-num)
1950- labels. each( check-string)
1951-
19521976 # Constants
19531977 label-length = labels. length()
19541978 value-length = values. length()
@@ -2068,10 +2092,6 @@ fun bar-chart-from-list(labels :: CL.LoS, values :: CL.LoN) -> DataSeries block:
20682092 Consume labels, a list of string, and values, a list of numbers
20692093 and construct a bar chart
20702094 ```
2071- # Type Checking
2072- values. each( check-num)
2073- labels. each( check-string)
2074-
20752095 # Constants
20762096 label-length = labels. length()
20772097 value-length = values. length()
@@ -2115,67 +2135,48 @@ fun num-dot-chart-from-list(x-values :: CL.LoN) -> DataSeries block:
21152135 } ^ dot-plot-series
21162136end
21172137
2118- fun image-num-dot-chart-from-list( images :: CL . LoI , x-values :: CL . LoN ) -> DataSeries block :
2138+ fun image-num-dot-chart-from-list( images :: CL . LoI , x-values :: CL . LoN ) -> DataSeries :
21192139 doc: ```
21202140 Consume unordered, possibly-repeating lists of image-labels and numbers,
21212141 and construct a dot chart
21222142 ```
2123- x-values. each( check-num)
2124- when x-values. length() == 0 :
2125- raise( ERR . message-exception( "num-dot-chart: can't have empty data" ))
2126- end
2127- images. each( check-image)
2128- when images. length() <> x-values. length() :
2129- raise( ERR . message-exception( "num-dot-chart: the lists of numbers and images must have the same length" ))
2130- end
2131- default-dot-plot-series. {
2132- ps: map3( get-dot-point, x-values, x-values. map( { ( _) : '' } ) , images. map( some)) ,
2133- } ^ dot-plot-series
2143+ num-dot-chart-from-list( x-values). image-labels( images)
21342144end
21352145
2136- fun labeled-num-dot-chart-from-list( labels :: CL . LoS , x-values :: CL . LoN ) -> DataSeries block :
2146+ fun labeled-num-dot-chart-from-list( labels :: CL . LoS , x-values :: CL . LoN ) -> DataSeries :
21372147 doc: ```
21382148 Consume unordered, possibly-repeating lists of labels and numbers,
21392149 and construct a dot chart
21402150 ```
2141- x-values. each( check-num)
2142- when x-values. length() == 0 :
2143- raise( ERR . message-exception( "num-dot-chart: can't have empty data" ))
2144- end
2145- labels. each( check-string)
2146- when labels. length() <> x-values. length() :
2147- raise( ERR . message-exception( "num-dot-chart: the lists of numbers and labels must have the same length" ))
2148- end
2149- default-dot-plot-series. {
2150- ps: map3( get-dot-point, x-values, labels, x-values. map( { ( _) : none} )) ,
2151- } ^ dot-plot-series
2151+ num-dot-chart-from-list( x-values). labels( labels)
21522152end
21532153
2154- fun dot-chart-from-list( input-labels :: CL . LoS ) -> DataSeries block:
2154+ fun get-cat-dot-point( label :: String , category :: String , optimg :: Option <IM . Image >) -> CategoricalDotPoint :
2155+ { label: label, category: category, image: optimg }
2156+ end
2157+ fun dot-chart-from-list( categories :: CL . LoS ) -> DataSeries block:
21552158 doc: ```
2156- Consume a list of string-values and construct a dot chart
2159+ Consume a list of string categories and construct a dot chart
21572160 ```
21582161
21592162 # Edge Case Error Checking
2160- when input-labels . length() == 0 :
2163+ when categories . length() == 0 :
21612164 raise( ERR . message-exception( "dot-chart: can't have empty data" ))
21622165 end
21632166
2164- # Type Checking
2165- input-labels. each( check-string)
2166-
2167- # Walk through the (sorted) values, creating lists of labels and counts
2168- unique-counts = for fold( acc from [ SD . mutable-string-dict: ] , label from input-labels) block:
2169- acc. set-now( label, acc. get-now( label). or-else( 0 ) + 1 )
2170- acc
2171- end
2172-
2173- labels = unique-counts. keys-list-now(). sort()
21742167 default-categorical-dot-plot-series. {
2175- ps: labels . map( { ( l ) : { label : l, count : unique-counts . get-value-now ( l ) }} )
2168+ ps: categories . map( get-cat-dot-point ( '' , _, none ) )
21762169 } ^ categorical-dot-plot-series
21772170end
21782171
2172+ fun image-dot-chart-from-list( images :: CL . LoI , categories :: CL . LoS ) -> DataSeries :
2173+ doc: ```
2174+ Consume unordered, possibly-repeating lists of images and categories,
2175+ and construct a dot chart
2176+ ```
2177+ dot-chart-from-list( categories). image-labels( images)
2178+ end
2179+
21792180fun grouped-bar-chart-from-list(
21802181 labels :: CL . LoS ,
21812182 value-lists :: CL . LoLoN ,
@@ -2205,11 +2206,6 @@ fun grouped-bar-chart-from-list(
22052206 raise( ERR . message-exception( 'grouped-bar-chart: labels and legends should have the same length' ))
22062207 end
22072208
2208- # Typechecking each input
2209- value-lists. each( _. each( check-num))
2210- labels. each( check-string)
2211- legends. each( check-string)
2212-
22132209 { max-positive-height; max-negative-height} = multi-prep-axis( grouped, rational-values)
22142210
22152211 # Constructing the Data Series
@@ -2254,11 +2250,6 @@ fun stacked-bar-chart-from-list(
22542250 raise( ERR . message-exception( 'stacked-bar-chart: labels and legends should have the same length' ))
22552251 end
22562252
2257- # Typechecking the input
2258- value-lists. each( _. each( check-num))
2259- labels. each( check-string)
2260- legends. each( check-string)
2261-
22622253 { max-positive-height; max-negative-height} = multi-prep-axis( absolute, rational-values)
22632254
22642255 # Constructing the Data Series
@@ -2421,10 +2412,6 @@ fun image-histogram-from-list(images :: CL.LoI, values :: CL.LoN) -> DataSeries
24212412 Consume images and numbers, then construct a histogram matching those
24222413 images to the original histogram bricks
24232414 ```
2424- # Type Checking
2425- images. each( check-image)
2426- values. each( check-num)
2427-
24282415 default-histogram-series. {
24292416 vals: map3( get-histogram-value, values, values. map( { ( _) : '' } ) , images. map( some))
24302417 } ^ histogram-series
@@ -2916,6 +2903,7 @@ from-list = {
29162903 dot-chart: dot-chart-from-list,
29172904 num-dot-chart: num-dot-chart-from-list,
29182905 image-num-dot-chart: image-num-dot-chart-from-list,
2906+ image-dot-chart: image-dot-chart-from-list,
29192907 labeled-num-dot-chart: labeled-num-dot-chart-from-list,
29202908 image-bar-chart: image-bar-chart-from-list,
29212909 grouped-bar-chart: grouped-bar-chart-from-list,
0 commit comments