Socket
Socket
Sign inDemoInstall

vega-lite

Package Overview
Dependencies
Maintainers
2
Versions
470
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-lite - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

src/compile/data/bin.js

50

CONTRIBUTING.md

@@ -43,28 +43,42 @@ # Contributing

1. Make sure you have node.js. (For mac users, we recommend using
[homebrew](http://brew.sh) and simply run `brew install node`.)
1. Make sure you have [node.js](https://nodejs.org/en/). For mac users, we recommend using [homebrew](http://brew.sh) and simply run:
2. clone this repository and cd into your local clone of the repository, and install all the npm dependencies:
```sh
brew install node
```
```sh
git clone https://github.com/vega/vega-lite.git
cd vega-lite
npm install
```
2. Clone this repository and cd into your local clone of the repository, and install all the npm dependencies:
Now you should be able to build and test the code.
```sh
git clone https://github.com/vega/vega-lite.git
cd vega-lite
npm install
```
3. To make the gallery works, you need to install bower and its dependencies:
Now you should be able to build and test the code.
3. To make the gallery work, you need to install [bower](http://bower.io/) and its dependencies:
```sh
npm install -g bower
bower install
```
```sh
npm install -g bower
bower install
```
4. To serve the website and documentation, you will need [ruby](https://www.ruby-lang.org/en/), [bundler](http://bundler.io/) and [Jekyll](https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/).
4. To serve the website and documentation, you also have to [install Jekyll with Github Pages Gem](https://help.github.com/articles/using-jekyll-with-pages/#installing-jekyll).
First, make sure you have ruby installed (If you do not, run `brew install ruby` on Mac will install it).
Then, run `gem install bundler`. Finally, simply run `bundle install` to install jekyll and its dependencies
(we already have the `Gemfile` in the repo).
For ruby, Mac users can use [homebrew](http://brew.sh) to add it:
```sh
brew install ruby
```
For bundler:
```sh
gem install bundler
```
For jekyll and its dependencies, because we already have the `Gemfile` in the repo, you can simply run:
```sh
bundle install
```
## Directory Structure

@@ -71,0 +85,0 @@

@@ -1,1 +0,1 @@

["area","area_vertical","bar","bar_1d","bar_aggregate","bar_aggregate_size","bar_aggregate_vertical","bar_filter_calc","bar_grouped","bar_grouped_horizontal","bar_layered_transparent","bar_yearmonth","bubble_health_income","circle","github_punchcard","histogram","layer_bar_line","layer_bar_line_union","layer_histogram","layer_line_color_rule","line","line_color","line_detail","line_monotone","line_month","line_slope","line_step","minimal","point_1d","point_color","point_dot_timeunit_color","point_filled","point_ordinal_color","scatter","scatter_aggregate_detail","scatter_binned","scatter_binned_color","scatter_binned_size","scatter_bubble","scatter_color","scatter_color_custom","scatter_color_order","scatter_color_ordinal","scatter_color_ordinal_custom","scatter_color_quantitative","scatter_color_shape_constant","scatter_colored_with_shape","scatter_connected","scatter_log","scatter_opacity","square","stacked_area","stacked_area_normalize","stacked_area_ordinal","stacked_area_stream","stacked_bar_1d","stacked_bar_h","stacked_bar_h_order","stacked_bar_normalize","stacked_bar_population","stacked_bar_size","stacked_bar_sum_opacity","stacked_bar_v","stacked_bar_weather","text_scatter_colored","text_table_heatmap","tick_dot","tick_dot_thickness","tick_strip","trellis_anscombe","trellis_bar","trellis_bar_histogram","trellis_barley","trellis_row_column","trellis_scatter","trellis_scatter_binned_row","trellis_stacked_bar"]
["area","area_vertical","bar","bar_1d","bar_aggregate","bar_aggregate_size","bar_aggregate_vertical","bar_filter_calc","bar_grouped","bar_grouped_horizontal","bar_layered_transparent","bar_yearmonth","circle","histogram","layer_bar_line","layer_bar_line_union","layer_histogram","layer_line_color_rule","line","line_color","line_detail","line_monotone","line_month","line_slope","line_step","minimal","point_1d","point_color","point_dot_timeunit_color","point_filled","point_ordinal_color","scatter","scatter_aggregate_detail","scatter_binned","scatter_binned_color","scatter_binned_size","scatter_bubble","scatter_color","scatter_color_custom","scatter_color_order","scatter_color_ordinal","scatter_color_ordinal_custom","scatter_color_quantitative","scatter_color_shape_constant","scatter_colored_with_shape","scatter_connected","scatter_log","scatter_opacity","square","stacked_area","stacked_area_normalize","stacked_area_ordinal","stacked_area_stream","stacked_bar_1d","stacked_bar_h","stacked_bar_h_order","stacked_bar_normalize","stacked_bar_population","stacked_bar_size","stacked_bar_sum_opacity","stacked_bar_v","stacked_bar_weather","text_scatter_colored","text_table_heatmap","tick_dot","tick_dot_thickness","tick_strip","trellis_anscombe","trellis_bar","trellis_bar_histogram","trellis_barley","trellis_row_column","trellis_scatter","trellis_scatter_binned_row","trellis_stacked_bar"]
{
"description": "A bubble plot showing the correlation between health and income for 187 countries in the world.",
"description": "A bubble plot showing the correlation between health and income for 187 countries in the world (modified from an example in Lisa Charlotte Rost's blog post 'One Chart, Twelve Charting Libraries' --http://lisacharlotterost.github.io/2016/05/17/one-chart-code/).",
"data": {

@@ -23,2 +23,2 @@ "url": "data/gapminder-health-income.csv",

"config": {"cell": {"width": 500,"height": 300}}
}
}

@@ -118,3 +118,3 @@ {

"name": "text_table_heatmap",
"title": "Table Heatmap",
"title": "Text Table Heatmap",
"galleryParameters": {

@@ -121,0 +121,0 @@ "backgroundSize": "250%",

{
"name": "vega-lite",
"author": "Jeffrey Heer, Dominik Moritz, Kanit \"Ham\" Wongsuphasawat",
"version": "1.0.9",
"version": "1.0.10",
"collaborators": [

@@ -40,2 +40,3 @@ "Kanit Wongsuphasawat <kanitw@gmail.com> (http://kanitw.yellowpigz.com)",

"test": "npm run schema && mocha --recursive --require source-map-support/register test examples",
"test:debug": "npm run schema && mocha --debug-brk --recursive --require source-map-support/register test examples",
"watch:build": "watchify src/vl.ts -p tsify -v -d -s vl -o 'exorcist vega-lite.js.map > vega-lite.js'",

@@ -42,0 +43,0 @@ "watch:test": "nodemon -x 'npm test && npm run lint'",

@@ -26,3 +26,3 @@

/**
* Color of axis line.
* Color of axis line.
*/

@@ -206,3 +206,3 @@ axisColor?: string;

export interface AxisProperties extends AxisConfig {
export interface Axis extends AxisConfig {
/**

@@ -209,0 +209,0 @@ * The rotation angle of the axis labels.

@@ -6,3 +6,3 @@ import {Channel, ROW, COLUMN, SHAPE, SIZE} from './channel';

*/
export interface BinProperties {
export interface Bin {
/**

@@ -9,0 +9,0 @@ * The minimum bin value to consider. If unspecified, the minimum value of the specified field is used.

@@ -43,2 +43,12 @@ "use strict";

});
var props = model.axis(channel).properties || {};
['grid'].forEach(function (group) {
var value = properties[group] ?
properties[group](model, channel, props[group] || {}, def) :
props[group];
if (value !== undefined && util_1.keys(value).length > 0) {
def.properties = def.properties || {};
def.properties[group] = value;
}
});
return def;

@@ -45,0 +55,0 @@ }

@@ -35,3 +35,3 @@ import {AxisOrient} from '../axis';

// TODO: replace any with Vega Axis Interface
let def = {
let def: any = {
type: type,

@@ -65,2 +65,16 @@ scale: model.scaleName(channel),

const props = model.axis(channel).properties || {};
// For now, only need to add grid properties here because innerAxis is only for rendering grid.
// TODO: support add other properties for innerAxis
['grid'].forEach(function(group) {
const value = properties[group] ?
properties[group](model, channel, props[group] || {}, def) :
props[group];
if (value !== undefined && keys(value).length > 0) {
def.properties = def.properties || {};
def.properties[group] = value;
}
});
return def;

@@ -67,0 +81,0 @@ }

@@ -1,2 +0,2 @@

import {AxisOrient, AxisProperties} from '../axis';
import {AxisOrient, Axis} from '../axis';
import {COLUMN, ROW, X, Y, Channel} from '../channel';

@@ -82,3 +82,3 @@ import {defaultConfig, Config} from '../config';

private _initAxis(facet: Facet, config: Config, child: Model): Dict<AxisProperties> {
private _initAxis(facet: Facet, config: Config, child: Model): Dict<Axis> {
return [ROW, COLUMN].reduce(function(_axis, channel) {

@@ -105,3 +105,3 @@ if (facet[channel]) {

return _axis;
}, {} as Dict<AxisProperties>);
}, {} as Dict<Axis>);
}

@@ -273,3 +273,3 @@

public assembleLayout(layoutData: VgData[]): VgData[] {
// Postfix traversal – layout is assembled bottom-up
// Postfix traversal – layout is assembled bottom-up
this._child.assembleLayout(layoutData);

@@ -276,0 +276,0 @@ return assembleLayout(this, layoutData);

import {COLOR, SIZE, SHAPE, Channel} from '../channel';
import {FieldDef} from '../fielddef';
import {LegendProperties} from '../legend';
import {Legend} from '../legend';
import {title as fieldTitle} from '../fielddef';

@@ -82,3 +82,3 @@ import {AREA, BAR, TICK, TEXT, LINE, POINT, CIRCLE, SQUARE} from '../mark';

export function offset(legend: LegendProperties, fieldDef: FieldDef) {
export function offset(legend: Legend, fieldDef: FieldDef) {
if (legend.offset !== undefined) {

@@ -90,3 +90,3 @@ return legend.offset;

export function orient(legend: LegendProperties, fieldDef: FieldDef) {
export function orient(legend: Legend, fieldDef: FieldDef) {
const orient = legend.orient;

@@ -99,3 +99,3 @@ if (orient) {

export function title(legend: LegendProperties, fieldDef: FieldDef) {
export function title(legend: Legend, fieldDef: FieldDef) {
if (typeof legend !== 'boolean' && legend.title) {

@@ -108,3 +108,3 @@ return legend.title;

export function formatMixins(legend: LegendProperties, model: UnitModel, channel: Channel) {
export function formatMixins(legend: Legend, model: UnitModel, channel: Channel) {
const fieldDef = model.fieldDef(channel);

@@ -111,0 +111,0 @@

@@ -1,2 +0,2 @@

import {AxisProperties} from '../axis';
import {Axis} from '../axis';
import {Channel, X, COLUMN} from '../channel';

@@ -7,3 +7,3 @@ import {Config, CellConfig} from '../config';

import {FieldDef, FieldRefOption, field} from '../fielddef';
import {LegendProperties} from '../legend';
import {Legend} from '../legend';
import {Scale, ScaleType} from '../scale';

@@ -86,5 +86,5 @@ import {BaseSpec} from '../spec';

protected _axis: Dict<AxisProperties>;
protected _axis: Dict<Axis>;
protected _legend: Dict<LegendProperties>;
protected _legend: Dict<Legend>;

@@ -309,7 +309,7 @@ protected _config: Config;

public axis(channel: Channel): AxisProperties {
public axis(channel: Channel): Axis {
return this._axis[channel];
}
public legend(channel: Channel): LegendProperties {
public legend(channel: Channel): Legend {
return this._legend[channel];

@@ -316,0 +316,0 @@ }

@@ -171,19 +171,27 @@ "use strict";

else if (fieldDef.bin) {
return scale.type === scale_1.ScaleType.ORDINAL ? {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_range' }),
sort: {
field: model.field(channel, { binSuffix: '_start' }),
op: 'min'
}
} : channel === channel_1.COLOR ? {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_start' })
} : {
data: model.dataTable(),
field: [
model.field(channel, { binSuffix: '_start' }),
model.field(channel, { binSuffix: '_end' })
]
};
if (scale.type === scale_1.ScaleType.ORDINAL) {
return {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_range' }),
sort: {
field: model.field(channel, { binSuffix: '_start' }),
op: 'min'
}
};
}
else if (channel === channel_1.COLOR) {
return {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_start' })
};
}
else {
return {
data: model.dataTable(),
field: [
model.field(channel, { binSuffix: '_start' }),
model.field(channel, { binSuffix: '_end' })
]
};
}
}

@@ -190,0 +198,0 @@ else if (sort) {

@@ -247,22 +247,28 @@ // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#11-ambient-declarations

} else if (fieldDef.bin) { // bin
return scale.type === ScaleType.ORDINAL ? {
if (scale.type === ScaleType.ORDINAL) {
// ordinal bin scale takes domain from bin_range, ordered by bin_start
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_range' }),
sort: {
field: model.field(channel, { binSuffix: '_start' }),
op: 'min' // min or max doesn't matter since same _range would have the same _start
}
} : channel === COLOR ? {
return {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_range' }),
sort: {
field: model.field(channel, { binSuffix: '_start' }),
op: 'min' // min or max doesn't matter since same _range would have the same _start
}
};
} else if (channel === COLOR) {
// Currently, binned on color uses linear scale and thus use _start point
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_start' })
} : {
return {
data: model.dataTable(),
field: model.field(channel, { binSuffix: '_start' })
};
} else {
// other linear bin scale merges both bin_start and bin_end for non-ordinal scale
data: model.dataTable(),
field: [
model.field(channel, { binSuffix: '_start' }),
model.field(channel, { binSuffix: '_end' })
]
};
return {
data: model.dataTable(),
field: [
model.field(channel, { binSuffix: '_start' }),
model.field(channel, { binSuffix: '_end' })
]
};
}
} else if (sort) { // have sort -- only for ordinal

@@ -269,0 +275,0 @@ return {

import {AggregateOp} from '../aggregate';
import {AxisProperties} from '../axis';
import {Axis} from '../axis';
import {X, Y, TEXT, PATH, ORDER, Channel, UNIT_CHANNELS, UNIT_SCALE_CHANNELS, NONSPATIAL_SCALE_CHANNELS, supportMark} from '../channel';

@@ -9,3 +9,3 @@ import {defaultConfig, Config, CellConfig} from '../config';

import {FieldDef, FieldRefOption, field} from '../fielddef';
import {LegendProperties} from '../legend';
import {Legend} from '../legend';
import {Mark, TEXT as TEXTMARK} from '../mark';

@@ -106,3 +106,3 @@ import {Scale, ScaleType} from '../scale';

private _initAxis(encoding: Encoding, config: Config): Dict<AxisProperties> {
private _initAxis(encoding: Encoding, config: Config): Dict<Axis> {
return [X, Y].reduce(function(_axis, channel) {

@@ -120,6 +120,6 @@ // Position Axis

return _axis;
}, {} as Dict<AxisProperties>);
}, {} as Dict<Axis>);
}
private _initLegend(encoding: Encoding, config: Config): Dict<LegendProperties> {
private _initLegend(encoding: Encoding, config: Config): Dict<Legend> {
return NONSPATIAL_SCALE_CHANNELS.reduce(function(_legend, channel) {

@@ -135,3 +135,3 @@ if (vlEncoding.has(encoding, channel)) {

return _legend;
}, {} as Dict<LegendProperties>);
}, {} as Dict<Legend>);
}

@@ -138,0 +138,0 @@

// utility for a field definition object
import {AggregateOp, AGGREGATE_OPS} from './aggregate';
import {AxisProperties} from './axis';
import {BinProperties} from './bin';
import {LegendProperties} from './legend';
import {Axis} from './axis';
import {Bin} from './bin';
import {Legend} from './legend';
import {Scale} from './scale';

@@ -25,3 +25,3 @@ import {SortField, SortOrder} from './sort';

timeUnit?: TimeUnit;
bin?: boolean | BinProperties;
bin?: boolean | Bin;
aggregate?: AggregateOp;

@@ -51,6 +51,6 @@

export interface PositionChannelDef extends ChannelDefWithScale {
axis?: boolean | AxisProperties;
axis?: boolean | Axis;
}
export interface ChannelDefWithLegend extends ChannelDefWithScale {
legend?: LegendProperties;
legend?: Legend;
}

@@ -57,0 +57,0 @@

@@ -63,3 +63,3 @@ export interface LegendConfig {

/**
* The color of the legend symbol,
* The color of the legend symbol,
*/

@@ -108,3 +108,3 @@ symbolColor?: string;

*/
export interface LegendProperties extends LegendConfig {
export interface Legend extends LegendConfig {
/**

@@ -111,0 +111,0 @@ * An optional formatting pattern for legend labels. Vega uses D3\'s format pattern.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc