Last active
April 28, 2022 23:49
-
-
Save a-poor/24aeeee763e519bf260c4115afa83847 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<svg | |
xmlns="http://www.w3.org/2000/svg" | |
xml:lang="en" | |
xmlns:xlink="http://www.w3.org/1999/xlink" | |
viewBox="0 0 600 400" | |
width="600"> | |
<!-- Set the background color --> | |
<rect | |
id="background" | |
x="0" | |
y="0" | |
width="600" | |
height="400" | |
fill="{{ layout.color.background }}" | |
/> | |
<!-- Create the Scatterplot --> | |
<g id="plot-layer"> | |
{%- for p in data.data %} | |
<circle | |
cx="{{ xscale(p.time) }}" | |
cy="{{ yscale(p.price) }}" | |
r="{{ layout.plot.point_radius }}" | |
{% if p.callout -%} | |
fill="{{ layout.color.color_on }}" | |
{% else -%} | |
fill="{{ layout.color.color_off }}" | |
{% endif -%} | |
/> | |
{%- endfor %} | |
</g> | |
<!-- Draw the Axis, Ticks, & Labels --> | |
<g id="axis-layer"> | |
<!-- Draw the axis --> | |
<polyline | |
points=" | |
{{ layout.plot.xmin }} {{ layout.plot.ymin }} | |
{{ layout.plot.xmin }} {{ layout.plot.ymax }} | |
{{ layout.plot.xmax }} {{ layout.plot.ymax }}" | |
stroke="{{ layout.color.axis }}" | |
stroke-linecap="round" | |
fill="transparent" | |
/> | |
<!-- Draw the yaxis label (rotated) --> | |
<g transform="translate(0,20)"> | |
<text | |
x="30" | |
y="176.5" | |
fill="{{ layout.color.axis }}" | |
font-family="helvetica" | |
text-align="center" | |
transform="rotate(-90,30,176.5)" | |
> | |
{{ data.ylabel }} | |
</text> | |
</g> | |
<!-- Draw the yticks --> | |
<g id="yticks"> | |
{% for t in yticks %} | |
<line | |
x1="{{ layout.plot.xmin }}" | |
y1="{{ t.pos }}" | |
x2="{{ layout.plot.xmin - layout.plot.pad }}" | |
y2="{{ t.pos }}" | |
stroke="{{ layout.color.axis }}" | |
stroke-linecap="round" | |
/> | |
<text | |
x="{{ layout.plot.xmin }}" | |
y="{{ t.pos }}" | |
fill="{{ layout.color.axis }}" | |
font-family="helvetica" | |
text-anchor="end" | |
dx="-15" | |
dy="5" | |
font-weight="lighter" | |
> | |
{{ t.text }} | |
</text> | |
{%- endfor %} | |
</g> | |
<!-- Draw the x axis label --> | |
<text | |
x="322.5" | |
y="350" | |
fill="{{ layout.color.axis }}" | |
font-family="helvetica" | |
text-anchor="middle" | |
> | |
{{ data.xlabel }} | |
</text> | |
<!-- Draw the xticks --> | |
<g id="xticks"> | |
{%- for t in xticks -%} | |
<line | |
x1="{{ t.pos }}" | |
y1="{{ layout.plot.ymax }}" | |
x2="{{ t.pos }}" | |
y2="{{ layout.plot.ymax + layout.plot.pad }}" | |
stroke="{{ layout.color.axis }}" | |
stroke-linecap="round" | |
/> | |
<text | |
x="{{ t.pos }}" | |
y="{{ layout.plot.ymax }}" | |
fill="{{ layout.color.axis }}" | |
font-family="helvetica" | |
text-anchor="middle" | |
dx="0" | |
dy="25" | |
font-weight="lighter" | |
> | |
{{ t.text }} | |
</text> | |
{% endfor -%} | |
</g> | |
</g> | |
<!-- Add the title, subtitle, & description --> | |
<g id="text-layer"> | |
<text | |
x="15" | |
y="40" | |
style="font-family: helvetica; font-size: 28px; font-weight: normal;" | |
fill="{{ layout.color.title }}" | |
> | |
{{ data.title }} | |
</text> | |
<text | |
x="15" | |
y="70" | |
style="font-family: helvetica; font-size: 18px; font-weight: normal;" | |
fill="{{ layout.color.subtitle }}"> | |
{{ data.subtitle }} | |
</text> | |
<text | |
x="15" | |
y="385" | |
style="font-family: helvetica; font-size: 10px; font-weight: normal;" | |
fill="{{ layout.color.caption }}"> | |
{{ data.caption }} | |
</text> | |
</g> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment