Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects + Introducing Prism Ske…

综合编程 2018-06-04

NOTE: There is some iframe d content in this post and you can bust out of it if you want to see the document in a full browser window.

Also, apologies for some lingering GitHub links. I’m waiting for all the repos to import into to other services and haven’t had time to setup my own self-hosted public instance of any community-usable git-ish environment yet.

And So It Begins

After seeing Fira Sans in action in presentations at eRum 2018 I felt compelled to add support hrbrthemes support for it so I made a firasans extension to it that uses Fira Sans Condensed and Fira Code fonts for ggplot2 graphics.

But I rly wanted to go the extra mile and make an R Markdown theme for it, but I’m weary of both jQuery & Bootstrap, plus prefer Prism over HighlightJS. So I started work on “Prism Skeleton”, which is an R Markdown template that has most of the features you would expect and some new ones, plus used Prism and Fira Sans/Code. You can try it out on your own if you use markdowntemplates but the “production” version is likely going to eventually go into the firasans package. I uses markdowntemplates as a playground for R Markdown experiments.

The source for the iframe at the end of this document is here: https://rud.is/dl/hello-dorling.Rmd . There are some notable features (I’ll repeat a few from above):

  • Fira Sans for headers and text
  • Fira Code for all monospaced content (including source code)
  • No jQuery
  • No Bootstrap (it uses the ‘Skeleton’ CSS framework)
  • No HighightJS (it uses the ‘Prism” highlighter)
  • Extended YAML parameters (more on that in a bit)
  • Defaults to fig.retina=2 and the use of optipng or pngquant for PNG compression (so it expects them to be installed — ref this post by Zev Ross for more info and additional image use tips)

“What’s this about ‘Dorling’?”

Oh, yes. You can read the iframe or busted out document for that bit. It’s a small package to make it easier to create Dorling cartograms based on previous work by @datagistips .

“You said something about ‘extended YAML’?”

Aye. Here’s the YAML excerpt from the Dorling Rmd :

title: "Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)"
author: "boB Rudis"
navlink: "[rud.is](https://rud.is/b/)"
  type: "article"
  title: "Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)"
  url: "https://github.com/hrbrmstr/spdorling"
  - content: '[GitLab](https://gitlab.com/hrbrmstr)
  - content: 'This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.'
date: "`r Sys.Date()`"
output: markdowntemplates::prismskel

The title , author & date should be familiar fields but the author and date get some different placement since the goal is more of a flowing document than academic report.

If navlink is present (it’s not required) there will be a static bar at the top of the HTML document with a link on the right (any content, really, but a link is what’s in the example). Remove navlink and no bar will be there.

The og section is for open graph tags and you customize them how you like. Open graph tags make it easier to share posts on social media or even Slack since they’ll auto-expand various content bits.

There’s also a custom footer (exclude it if you don’t want one) that can take multiple content sub-elements.

The goal isn’t so much to give you a 100% usable R Markdown template but something you can clone and customize for your own use. Since this example shows how to use custom fonts and a different code highlighter (which meant using some custom knitr hooks), it should be easier to customize than some of the other ones in the template playground package. FWIW I plan on adapting this for a work template this week.

The other big customization is the use of Prism with a dark theme. Again, you can clone + customize this at-will but I may add config options for all Prism themes at some point (mostly if there is interest).


(Well, almost fin )

Kick the tyres on both the new template and the new package and drop suggestions here for the time being (until I get fully transitioned to a new git-hosting platform). One TODO for spdorling is to increase the point count for the circle polygons but I’m sure folks can come up with enhancement requests to the API after y’all have played with it for a while.

As noted a few times, the Rmd example with the Dorling cartograms is below.


Webpack打包构建太慢了?试试几个方法 Webpack是个很流行的打包工具,但其打包速度却一直被吐槽着 如果不用上一些打包的优化建议,单单打包两三个文件就能花上好几秒,放上几十个入口文件依赖几百上千个包的话,几分钟十几分钟妥妥的 本文整理了常见的一些方法,部分使用之后就看到了很大改善,部分没什么明显的变化,也可能是项目规模还不够大...
Kubernetes配置最佳实践 (题图:青岛 May 26,2017) 前言 本文档旨在汇总和强调用户指南、快速开始文档和示例中的最佳实践。该文档会很很活跃并持续更新中。如果你觉得很有用的最佳实践但是本文档中没有包含,欢迎给我们提Pull Request。 本文已上传到 kubernetes-hand...
Search-insensitive letters in the text box I am trying to search the contents using jquery. Search option working fine. But, I have faced some case insensitive problem here. My full codes on js...
Using #REST in #JavaScript to update #ProjectOnlin... Using #REST in #JavaScript to update #ProjectOnline project custom fields #PPM #PMOT #jQuery #Office365 ...
A Complete CMS with No Server and 18 Lines of Code... A few months ago we released an open source project, Netlify CMS. We’ve thoroughly enjoyed opening this up to the community for contributions (and we...