This repository was archived by the owner on Jan 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Style guide
Alison Appling edited this page Oct 11, 2017
·
16 revisions
Viz collaborations are smoother when we adopt a consistent code style. Here is the style we have chosen:
- Viz.yaml element ids:
my-element-mobile - R functions that build viz.yaml elements:
process.my_element() - Other R function names:
my_function_name - R variable names:
my.variable.name - File names:
scripts/process/process.my_element.R,example_data_file.tsv - CSS classes and IDs:
fig-text - JavaScript functions and variables:
myVariableName,myFunctionName
- In JavaScript, use namespacing to put related things together and to keep variables localized
- Fetch/process/visualize functions should each produce a single file (at the viz 'location') for the sake of clean dependency management.
Within the constraints of efficiency and practicality, and allowing for exceptions:
- Fetch functions should preserve a raw or near-raw data format. Limit any processing to actions you're sure no one will need to revise during the viz sprint, so that downloads can be infrequent.
- The process phase should bring the data all the way from just-fetched to visualization-ready. As much as possible, say 'yes' to tabular and spatial data manipulation, 'no' to SVG, CSS, and JavaScript. There can be 2+ process phases for a single dataset.
- Visualization functions should produce static (but interaction-ready) graphics.
- The publish phase is the ideal place for layout, styling, and interactivity.
Collaborating
Using vizlab
Specific concepts