Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v2.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rousan committed Sep 11, 2019
2 parents cb2c3df + 4660bb6 commit c18ab2e
Show file tree
Hide file tree
Showing 26 changed files with 937 additions and 410 deletions.
2 changes: 1 addition & 1 deletion dist/datamodel.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/datamodel.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</head>

<body>
<script src="./samples/sample-with-split.js"></script>
<!-- <script src="./samples/example3.js"></script> -->
<!-- <script src="./samples/sample-with-split.js"></script> -->
<script src="./samples/example3.js"></script>
</body>

</html>
242 changes: 124 additions & 118 deletions example/samples/example3.js
Original file line number Diff line number Diff line change
@@ -1,145 +1,151 @@
/* eslint-disable */

d3.json('../data/cars.json', (data) => {
let jsonData = data;
const schema = [{
name: 'Name',
type: 'dimension'
const data = [
{
"xvalue": -19800000,
"xvalue0": 63052200000,
"xdim": -19800000,
"yvalue": undefined,
},
{
"xvalue": 63052200000,
"xvalue0": 126210600000,
"xdim": 63052200000
},
{
"xvalue": 126210600000,
"xvalue0": 189282600000,
"xdim": 126210600000
},
{
name: 'birthday',
type: 'dimension',
subtype: 'temporal',
format: '%Y-%m-%d'
"xvalue": 189282600000,
"xvalue0": 252441000000,
"xdim": 189282600000
},
{
name: 'roll',
type: 'measure',
defAggFn: "avg",
as: "roll2"
"xvalue": 252441000000,
"xvalue0": 315513000000,
"xdim": 252441000000
},
{
"xvalue": 315513000000,
"xvalue0": 378671400000,
"xdim": 315513000000
},
{
"xvalue": 378671400000,
"xdim": 378671400000
}
];
]

const data = [
const schema = [
{
"name": "yvalue",
"type": "measure"
},
{
"name": "xvalue",
"type": "measure"
},
{
name: 'Rousan',
birthday: '1995-07-05',
roll: 2
"name": "yvalue0",
"type": "measure"
},
{
name: 'Miles_per_Gallon',
type: 'measure'
"name": "xvalue0",
"type": "measure"
},
{
"name": "xdim",
"type": "dimension",
"subtype": "temporal"
},
{
"name": "ydim",
"type": "dimension",
"subtype": "temporal"
}
]

window.a = new DataModel(data, schema);

const jsonData1 = [
{
"yvalue": 0,
"yvalue0": 50,
"ydim": 0
},
{
name: 'Displacement',
type: 'measure'
"yvalue": 50,
"yvalue0": 100,
"ydim": 50
},
{
name: 'Horsepower',
type: 'measure'
"yvalue": 100,
"yvalue0": 150,
"ydim": 100
},
{
name: 'Weight_in_lbs',
type: 'measure'
"yvalue": 150,
"yvalue0": 200,
"ydim": 150
},
{
name: 'Acceleration',
type: 'measure'
"yvalue": 200,
"yvalue0": 250,
"ydim": 200
},
{
name: 'Origin',
type: 'dimension'
"yvalue": 250,
"yvalue0": 300,
"ydim": 250
},
{
name: 'Akash',
birthday: '1994-01-03',
roll: 120
"yvalue": 300,
"yvalue0": 350,
"ydim": 300
},
{
name: 'Rousan',
birthday: '1995-07-06',
roll: 93
"yvalue": 350,
"yvalue0": 400,
"ydim": 350
},
{
"yvalue": 400,
"yvalue0": 450,
"ydim": 400
},
{
"yvalue": 450,
"ydim": 450
}
];


const dm = new DataModel(data, schema);
const dm2 = dm.project(["name", "roll"]);
// const schema = [
// { name: 'Name', type: 'dimension' },
// { name: 'HorsePower', type: 'measure' },
// { name: 'Origin', type: 'dimension' }
// ];
// const data = [
// { Name: 'chevrolet chevelle malibu', Horsepower: 130, Origin: 'USA' },
// { Name: 'citroen ds-21 pallas', Horsepower: 115, Origin: 'Europe' },
// { Name: 'datsun pl510', Horsepower: 88, Origin: 'Japan' },
// { Name: 'amc rebel sst', Horsepower: 150, Origin: 'USA' },
// ];
// const dt = new DataModel(schema, data);

// const dt2 = dt.select(fields => fields.Origin.value === 'USA');

// const selectedDm = dm.select(fields => fields.roll.value > 10 || fields.roll.value < 0);



// debugger;

// const groupedDm = dm.groupBy(["name"], {
// roll: (vals, cloneProvider, store) => {
// if (!store.clonedDm) {
// store.clonedDm = cloneProvider();
// }
// if (!store.avgRoll) {
// store.avgRoll = store.clonedDm.groupBy([""], { roll: "avg" }).getData().data[0][0];
// }

// return DataModel.Stats.avg(vals) - store.avgRoll;
// }
// });
// const calDm = dm.calculateVariable({
// name: "abc",
// type: "measure"
// }, ["roll", (roll, i, cloneProvider, store) => {
// if (!store.clonedDm) {
// store.clonedDm = cloneProvider();
// }
// if (!store.avgRoll) {
// store.avgRoll = store.clonedDm.groupBy([""], {roll: "avg"}).getData().data[0][0];
// }

// return store.avgRoll - roll;
// }]);

// const DataModel = window.DataModel;

// const data1 = [
// { profit: 10, sales: 20, city: 'a' },
// { profit: 15, sales: 25, city: 'b' },
// ];
// const schema1 = [
// { name: 'profit', type: 'measure' },
// { name: 'sales', type: 'measure' },
// { name: 'city', type: 'dimension' },
// ];
// const data2 = [
// { population: 200, city: 'a' },
// { population: 250, city: 'b' },
// ];
// const schema2 = [
// { name: 'population', type: 'measure' },
// { name: 'city', type: 'dimension' },
// ];
// const dataModel1 = new DataModel(data1, schema1, { name: 'ModelA' });
// const dataModel2 = new DataModel(data2, schema2, { name: 'ModelB' });
];

let rootData = new DataModel(jsonData, schema);
let dm = rootData.project(["Origin", "Acceleration"]);
let dm5 = DataModel.Operators.compose(
DataModel.Operators.groupBy(["Origin"]),
DataModel.Operators.select(f => f.Acceleration.value > 1000)
)(dm);
});
const schema1 = [
{
"name": "yvalue",
"type": "measure"
},
{
"name": "xvalue",
"type": "measure"
},
{
"name": "yvalue0",
"type": "measure"
},
{
"name": "xvalue0",
"type": "measure"
},
{
"name": "xdim",
"type": "dimension",
"subtype": "categorical"
},
{
"name": "ydim",
"type": "dimension",
"subtype": "categorical"
}
];

window.b = new DataModel(jsonData1, schema1);
Loading

0 comments on commit c18ab2e

Please sign in to comment.