Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
neocarto committed Mar 19, 2024
1 parent 63c803e commit bebd64d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
svg.plot({type:"header", fontSize: 30, text: "A Simple World Map", fill: "#267A8A", fontWeight: "bold", fontFamily: "Tangerine"})
return svg.render() // render
}
</code></pre><h2>Statistical cartography</h2><p>In addition of mapping static marks, the plot function lets you quickly create statistical maps (including legends) with very few parameters (and many others as options). Let's see some examples.</p><h3>Proportional symbols</h3><p>By using <a href="global.html#plot/prop"><code>type = &quot;prop&quot;</code></a>, you can design a map with proportionnal symbols. Find below a minimal example.</p><pre class="prettyprint source lang-js"><code>geoviz.plot({type = &quot;prop&quot;, data = *a geoJSON*, var = *a field*})
</code></pre><h2>Statistical cartography</h2><p>In addition of mapping static marks, the plot function lets you quickly create statistical maps (including legends) with very few parameters (and many others as options). Let's see some examples.</p><h3>Proportional symbols</h3><p>By using <a href="global.html#plot/prop"><code>type = &quot;prop&quot;</code></a>, you can design a map with proportionnal symbols (&quot;circle&quot;, &quot;square&quot;, &quot;halfcircle&quot;,&quot;spike&quot;). Find below a minimal example.</p><pre class="prettyprint source lang-js"><code>geoviz.plot({type = &quot;prop&quot;, data = *a geoJSON*, var = *a field*})
</code></pre><p>📚 <a href="global.html#plot/prop"><code>plot/prop()</code></a></p><p>🌏 live demo <a href="https://observablehq.com/@neocartocnrs/prop"><code>prop</code></a></p><h3>Choropleth</h3><p>By using <a href="global.html#plot/choro"><code>type = &quot;choro&quot;</code></a>, you can design a choropleth map. Find below a minimal example.</p><pre class="prettyprint source lang-js"><code>geoviz.plot({type = &quot;choro&quot;, data = *a geoJSON*, var = *a field*})
</code></pre><p>📚 <a href="global.html#plot/choro"><code>plot/choro()</code></a></p><p>🌏 live demo <a href="https://observablehq.com/@neocartocnrs/choropleth"><code>choropleth</code></a></p><h3>Typology</h3><p>By using <a href="global.html#plot/typo"><code>type = &quot;typo&quot;</code></a>, you can design a qualitative typo map. Find below a minimal example.</p><pre class="prettyprint source lang-js"><code>geoviz.plot({type = &quot;typo&quot;, data = *a geoJSON*, var = *a field*})
</code></pre><p>📚 <a href="global.html#plot/typo"><code>plot/typo()</code></a></p><p>🌏 live demo <a href="https://observablehq.com/@neocartocnrs/typo"><code>typology</code></a></p><h3>Proportional symbols + horopleth</h3><p>By using <a href="global.html#plot/propchoro"><code>type = &quot;propchoro&quot;</code></a>, you can design a map with proportionnal symbols with graduated colors. Find below a minimal example.</p><pre class="prettyprint source lang-js"><code>geoviz.plot({type = &quot;propchoro&quot;, data = *a geoJSON*, var1 = *a field*, var2 = *a field*})
Expand Down
10 changes: 4 additions & 6 deletions docs/mark_square.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,14 @@
)
.attr(
"x",
(d) =>
path.centroid(d.geometry)[0] + opts.dx - radius(d, opts.side) / 2
(d) => path.centroid(d.geometry)[0] + opts.dx - radius(d, opts.side)
)
.attr(
"y",
(d) =>
path.centroid(d.geometry)[1] + opts.dy - radius(d, opts.side) / 2
(d) => path.centroid(d.geometry)[1] + opts.dy - radius(d, opts.side)
)
.attr("width", (d) => radius(d, opts.side))
.attr("height", (d) => radius(d, opts.side))
.attr("width", (d) => radius(d, opts.side) * 2)
.attr("height", (d) => radius(d, opts.side) * 2)
.attr("visibility", (d) =>
isNaN(path.centroid(d.geometry)[0]) ? "hidden" : "visible"
);
Expand Down
22 changes: 19 additions & 3 deletions docs/plot_plot_prop.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@
id: unique(),
missing: "white",
k: 50,

fixmax: null,
leg_type: "nested",
leg_pos: [10, 10],
};

opts.k = opts.symbol == "square" ? 100 : 50;

opts = { ...opts, ...options };
let ids = `#${opts.id}`;

Expand All @@ -65,8 +66,18 @@

// LAYER OPTS

opts.r = opts.var;
opts.height = opts.var;
if (opts.symbol == "square") {
opts.side = opts.var;
}
if (opts.symbol == "spike") {
opts.height = opts.var;
}
if (opts.symbol == "circle") {
opts.r = opts.var;
}
if (opts.symbol == "halfcircle") {
opts.r = opts.var;
}

let layeropts = {};
Object.keys(opts)
Expand Down Expand Up @@ -120,6 +131,11 @@
? svg.legend.circles_nested(legopts)
: svg.legend.circles(legopts);
break;
case "square":
opts.leg_type == "nested"
? svg.legend.squares_nested(legopts)
: svg.legend.squares(legopts);
break;
case "spike":
svg.legend.spikes(legopts);
break;
Expand Down
23 changes: 20 additions & 3 deletions docs/plot_plot_propchoro.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,18 @@
svg.path({ datum: opts.data, fill: "#CCC", fillOpacity: 0.2 });
}

opts.r = opts.var1;
opts.height = opts.var1;
if (opts.symbol == "square") {
opts.side = opts.var1;
}
if (opts.symbol == "spike") {
opts.height = opts.var1;
}
if (opts.symbol == "circle") {
opts.r = opts.var1;
}
if (opts.symbol == "halfcircle") {
opts.r = opts.var1;
}

// CLASSIFY
opts.missing_fill = opts.missing;
Expand All @@ -116,7 +126,6 @@

opts.fill = (d) => classif.colorize(d.properties[opts.var2]);

// LAYER OPTS
let layeropts = {};
Object.keys(opts)
.filter((str) => str.slice(0, 3) != "leg")
Expand All @@ -128,6 +137,9 @@
case "circle":
svg.circle(layeropts);
break;
case "square":
svg.square(layeropts);
break;
case "spike":
svg.spike(layeropts);
break;
Expand Down Expand Up @@ -169,6 +181,11 @@
? svg.legend.circles_nested(legopts)
: svg.legend.circles(legopts);
break;
case "square":
opts.leg1_type == "nested"
? svg.legend.squares_nested(legopts)
: svg.legend.squares(legopts);
break;
case "spike":
svg.legend.spikes(legopts);
break;
Expand Down
23 changes: 20 additions & 3 deletions docs/plot_plot_proptypo.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,18 @@
svg.path({ datum: opts.data, fill: "#CCC", fillOpacity: 0.2 });
}

opts.r = opts.var1;
opts.height = opts.var1;
if (opts.symbol == "square") {
opts.side = opts.var1;
}
if (opts.symbol == "spike") {
opts.height = opts.var1;
}
if (opts.symbol == "circle") {
opts.r = opts.var1;
}
if (opts.symbol == "halfcircle") {
opts.r = opts.var1;
}

// CLASSIFY
opts.missing_fill = opts.missing;
Expand All @@ -108,7 +118,6 @@
opts.missing = false;
}

// LAYER OPTS
let layeropts = {};
Object.keys(opts)
.filter((str) => str.slice(0, 3) != "leg")
Expand All @@ -120,6 +129,9 @@
case "circle":
svg.circle(layeropts);
break;
case "square":
svg.square(layeropts);
break;
case "spike":
svg.spike(layeropts);
break;
Expand Down Expand Up @@ -159,6 +171,11 @@
? svg.legend.circles_nested(legopts)
: svg.legend.circles(legopts);
break;
case "square":
opts.leg1_type == "nested"
? svg.legend.squares_nested(legopts)
: svg.legend.squares(legopts);
break;
case "spike":
svg.legend.spikes(legopts);
break;
Expand Down

0 comments on commit bebd64d

Please sign in to comment.