diff --git a/src/trove/chart-images/geochart.png b/src/trove/chart-images/geochart.png new file mode 100644 index 0000000..5892342 Binary files /dev/null and b/src/trove/chart-images/geochart.png differ diff --git a/src/trove/chart.js.rkt b/src/trove/chart.js.rkt index 30c6f38..fbaeae0 100644 --- a/src/trove/chart.js.rkt +++ b/src/trove/chart.js.rkt @@ -182,6 +182,7 @@ (fun-spec (name "from-list.exploding-pie-chart") (arity 3)) (fun-spec (name "from-list.histogram") (arity 2)) (fun-spec (name "from-list.labeled-histogram") (arity 3)) + (fun-spec (name "from-list.geochart") (arity 3)) (fun-spec (name "render-chart") (arity 1)) (fun-spec (name "render-charts") (arity 1)) (constr-spec @@ -203,16 +204,19 @@ (name "histogram-series") (with-members (,bin-width-meth ,max-num-bins-meth ,min-num-bins-meth ,num-bins-meth))) + (constr-spec + (name "geochart-series") + (with-members ())) (data-spec (name "DataSeries") (type-vars ()) (variants ("function-plot-series" "line-plot-series" "scatter-plot-series" - "bar-chart-series" "pie-chart-series" "histogram-series")) + "bar-chart-series" "pie-chart-series" "histogram-series" "geochart-series")) (shared)) (data-spec (name "ChartWindow") (type-vars ()) - (variants ("bar-chart-window")) + (variants ("bar-chart-window" "plot-chart-window" "histogram-chart-window" "pie-chart-window" "geochart-window")) (shared ((method-spec (name "title") @@ -271,6 +275,9 @@ (constr-spec (name "pie-chart-window") (with-members ())) + (constr-spec + (name "geochart-window") + (with-members ())) )) @docmodule["chart"]{ @@ -591,6 +598,26 @@ a-series = from-list.labeled-histogram( } } + @function["from-list.geochart" + #:contract (a-arrow (L-of S) (L-of N) DataSeries) + #:args '(("region-labels" #f) ("values" #f)) + #:return (a-pred DataSeries (in-link "geochart-series")) + ]{ + Constructing a geochart series, which makes a map of the world and highlights @pyret{region-labels} on the map + in a range according to its @pyret{value}. Note that a given region-labels and value have the same index number in their respective lists. + The geochart will also show the range of values on the various regions, which higher values having a different color than lower values. + Note that the @pyret{region-labels} and @pyret{value} must be the same length. See more details at @(in-link "geochart-series"). + + A list of all the valid @pyret{region-labels} and their locations on the geochart can be found @link["https://developers.google.com/chart/interactive/docs/gallery/geochart#continent-hierarchy-and-codes" "here from Google Charts"]. + For example, adding "US" as a region label would color the United States of America, while "ZA" would color the region of South Africa. + + @examples{ +an-example-geochart-series = from-list.geochart( +[list: "US", "India","Pakistan", "Philippines", "Nigeria"], +[list: 251388301, 125344736, 110041604, 89800800, 79000000]) + } + } + @;############################################################################ @section{DataSeries} @@ -601,6 +628,7 @@ a-series = from-list.labeled-histogram( @constructor-spec["DataSeries" "bar-chart-series" opaque] @constructor-spec["DataSeries" "pie-chart-series" opaque] @constructor-spec["DataSeries" "histogram-series" opaque] + @constructor-spec["DataSeries" "geochart-series" opaque] )] @;################################ @@ -738,6 +766,23 @@ render-chart(a-series).display() } @(in-image "labeled-histogram") + @;################################ + @subsection{GeoChart Series} + + @constructor-doc["DataSeries" "geochart-series" opaque DataSeries]{ + A geochart series. + } + + @examples{ +an-example-geochart-series = from-list.geochart( +[list: "US", "India","Pakistan", "Philippines", "Nigeria"], +[list: 251388301, 125344736, 110041604, 89800800, 79000000]) + + +render-chart(an-example-geochart-series).display() + } + @(in-image "geochart") + @;############################################################################ @section{Renderers} @@ -755,6 +800,7 @@ render-chart(a-series).display() @item{@in-link{bar-chart-series} creates a @in-link{bar-chart-window}} @item{@in-link{pie-chart-series} creates a @in-link{pie-chart-window}} @item{@in-link{histogram-series} creates a @in-link{histogram-chart-window}} + @item{@in-link{geochart-series} creates a @in-link{geochart-window}} ] @examples{ @@ -792,6 +838,7 @@ a-chart-window = render-charts([list: series-1, series-2]) @constructor-spec["ChartWindow" "bar-chart-window" opaque] @constructor-spec["ChartWindow" "histogram-chart-window" opaque] @constructor-spec["ChartWindow" "plot-chart-window" opaque] + @constructor-spec["ChartWindow" "geochart-window" opaque] )] @;################################ @@ -848,4 +895,12 @@ a-chart-window = render-charts([list: series-1, series-2]) @method-doc["ChartWindow" "histogram-chart-window" "y-max"] @method-doc["ChartWindow" "histogram-chart-window" "x-axis"] @method-doc["ChartWindow" "histogram-chart-window" "y-axis"] -} + + @;################################ + @subsection{Geochart Chart Window} + + @constructor-doc["ChartWindow" "geochart-window" opaque ChartWindow]{ + A geochart chart window. + } + +} \ No newline at end of file