Save SVG in JS

To save a SVG when it is rendered in the page, you can write this in the console:

1
2
3
4
5
6
7
8
9
var svgData = $("#figureSvg")[0].outerHTML;
var svgBlob = new Blob([svgData], {type:"image/svg+xml;charset=utf-8"});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = "newesttree.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);

Read More

How to Draw a Horizon Chart with R

Commonly, line chart is used to show the temporal change of a variable. But, if the value has a large range, it could take a large space for the chart to show the whole change. Horizon chart dissolved the fluctuations in the line charts in several bands and overlap the bands to show the large range of the values in a relative narrow space. It benefit us to compare various variable in a short time.

Read More

CORS Error

To ensure the cyber security, JavaScript does not allow a webpage to load extra dataset from another website by default. If you add the resources by using an URL, the error massage Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://cl.ly/2wr4. This can be fixed by moving the resource to the same domain or enabling CORS. will be shown on the console.

Read More

Postgis Error on st_within

SRID is a spatial reference identifier. The SRID of WGS84 is 4326. In Postgis, the spatial query is based on the geometries have the same SRIDs. When using the PostGIS Shapefile Import/Export Manager, the SRID is shown.

Read More

Show Changes in Latex

It is not necessary to manually mark each change of the latex file. One can edit directly in the tex file, using latexdiff to mark the changes texts. One drawback is that when changing the titles of the figures and tables, the changes would note be properly marked.

Read More

Latex Footnote in Figure Caption

To add a footnote in a figure caption:

1
2
3
4
5
6
7
\begin{figure}[!ht]
\centering
\includegraphics[width=3in]{images/radar2.png}
\caption{A radar chart\protect\footnotemark ~shows overview of the advantages and disadvantages of map-based dashboard and storytelling map. }
\label{fig:comparison2}
\end{figure}
\footnotetext{The style referred to: https://www.visualcinnamon.com/2015/10/different-look-d3-radar-chart.html}

Read More

Convert Two-dimensional Table to One-dimensional Table

The test data is 2D data:

Test data

To convert two-dimensional table to one-dimensional table in JavaScript:

Read More

Load External Geojson to Leaflet

Geojson benefits the geo-data visualzing. Here we introduce two methods of loading external geojson to Leaflet.

Read More

Install Geopandas

GeoPandas provides extension to pandas. It makes geo-data processing and geo-visualization much easier. geojson can be parsed and visualized easily.

Read More

Multiple Linear Regression in R

Math model

1
Y = a1*X1 + a2*X2 + a3*X3 + ... + an*Xn + b

Read More