This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump the release version and make a build
- Loading branch information
Showing
11 changed files
with
5,433 additions
and
4,721 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* eslint-disable */ | ||
d3.json('../data/cars.json', (data) => { | ||
const jsonData = data; | ||
const schema = [ | ||
{ | ||
name: 'Name', | ||
type: 'dimension' | ||
}, | ||
{ | ||
name: 'Maker', | ||
type: 'dimension' | ||
}, | ||
{ | ||
name: 'Miles_per_Gallon', | ||
type: 'measure', | ||
defAggFn: 'avg' | ||
}, | ||
|
||
{ | ||
name: 'Displacement', | ||
type: 'measure' | ||
}, | ||
{ | ||
name: 'Horsepower', | ||
type: 'measure', | ||
defAggFn: 'avg' | ||
}, | ||
{ | ||
name: 'Weight_in_lbs', | ||
type: 'measure' | ||
}, | ||
{ | ||
name: 'Acceleration', | ||
type: 'measure', | ||
defAggFn: 'sum' | ||
}, | ||
{ | ||
name: 'Origin', | ||
type: 'dimension' | ||
}, | ||
{ | ||
name: 'Cylinders', | ||
type: 'dimension' | ||
}, | ||
{ | ||
name: 'Year', | ||
type: 'dimension', | ||
subtype: 'temporal', | ||
format: '%Y-%m-%d' | ||
} | ||
]; | ||
|
||
const env = muze(); | ||
const DataModel = muze.DataModel; | ||
|
||
let rootData = new DataModel(jsonData, schema); | ||
rootData = rootData.calculateVariable( | ||
{ | ||
name: 'CountVehicle', | ||
type: 'measure', | ||
defAggFn: 'count', | ||
numberFormat: val => parseInt(val, 10) | ||
}, | ||
['Name', () => 1] | ||
); | ||
env.data(rootData); | ||
|
||
// line chart | ||
env.canvas() | ||
.rows(['CountVehicle']) | ||
.columns(['Year']) | ||
.data(rootData) | ||
.width(450) | ||
.height(300) | ||
.title('Line Chart') | ||
.mount('#chart'); | ||
|
||
// stacked bar chart | ||
env.canvas() | ||
.rows(['CountVehicle']) | ||
.columns(['Year']) | ||
.data(rootData) | ||
.width(600) | ||
.color('Origin') | ||
.layers([{ | ||
mark: 'bar', | ||
transform: { | ||
type: 'stack' | ||
} | ||
}]) | ||
.height(300) | ||
.title('Stacked Bar Chart') | ||
.mount('#chart2'); | ||
|
||
// grouped bar chart with line | ||
env.canvas() | ||
.rows(['Miles_per_Gallon']) | ||
.columns(['Year']) | ||
.data(rootData) | ||
.width(1050) | ||
.color('Origin') | ||
.layers([{ | ||
mark: 'bar' | ||
}, { | ||
mark: 'line' | ||
}]) | ||
.height(300) | ||
.title('Grouped Bar Chart and Line') | ||
.mount('#chart3'); | ||
}); |
Oops, something went wrong.