Relationship between gasoline prices and driving habits in the US based on Driving Shifts Into Reverse by Hannah Fairfield. The New York Times (May 2, 2010).
This is an example DataPackage that demonstrates usage of "Vega Graph Specifications". This Demo Data Package based on this example.
To create graphs for your tabular DataPackage, the datapackage.json should include the views attribute that defines data views.
<script src="https://gist.github.com/anuveyatsu/8a3db6b83422fc7dc592bf1963fee275.js"></script>To use "Vega Graph Specification" specType
inside views
attribute should be set to vega
- line 36. You can use almost the same specifications inside spec
attribute, that are used for setting the vega graphs. Only difference is that in data
property, all url
and path
attributes are moved out. Instead of that, name
attribute is used to reference a dataset - line 42.
On line 183 we define the second view that uses "Simple Graph Spec", specType
inside views
attribute is set to simple
- line 186.
There are only 3 properties enough to define graph specifications. They should be set inside spec
attribute - line 187.
Attribute | Type | Description |
---|---|---|
type | String | line, bar, pie (defaults to line) |
group | String | Field name, that will be used as abscissa (usually date field) |
series | Array | Field name(s) that will be used as ordinate |
Outside of spec
attribute there are some other important parameters to note:
Attribute | Type | Description |
---|---|---|
name | String | Unique identifier for view within list of views (lines 51 and 62) |
title | String | Title for the graph (lines 52 and 63) |
resources | Array | Data sources for this spec. It can be either resource name or index. By default it is the first resource (lines 53 and 64) |
specType | String | Available options: simple, vega, plotly (Required) |