Skip to content

Example datapackage with two types of views: Simple and Vega

Notifications You must be signed in to change notification settings

datapackage-examples/mixed-views

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

S&P 500 index data including level, dividend, earnings and P/E ratio on a monthly basis since 1870. The S&P 500 (Standard and Poor's 500) is a free-float, capitalization-weighted index of the top 500 publicly listed stocks in the US (top 500 by market cap).

Views

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/881edf757c2ee3fe08b439d6c489c5ed.js"></script>

Simple Graph Specifications

On line 76 we define the first view that uses "Simple Graph Spec", specType inside views attribute is set to simple - line 79.

There are only 3 properties enough to define graph specifications. They should be set inside spec attribute - line 80.

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

Vega Graph Specifications

On line 86, we define the second view with vega spec. To use "Vega Graph Specification" specType inside views attribute should be set to vega - line 89. 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 96.

Other attributes of a "view" property

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.
title String Title for the graph.
resources Array Data sources for this spec. It can be either resource name or index. By default it is the first resource.
specType String Available options: simple, vega, plotly (Required).

About

Example datapackage with two types of views: Simple and Vega

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published