-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
4,616 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,2 @@ | ||
# Dependency directories | ||
node_modules/ | ||
|
||
examples/* |
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Muze</title> | ||
</head> | ||
|
||
<body> | ||
<div id="chart"></div> | ||
<p>Hello</p> | ||
<!-- <script src="./js/legend-samples/line-dashed.js"></script> --> | ||
<!-- <script src="./js/axis/sample4.js"></script> --> | ||
<!-- <script src="./js/test.js"></script> --> | ||
<!-- <script src="./js/word.js"></script> --> | ||
<!-- For testing examples exported from Mode use the script below --> | ||
<!-- <script src="./js/axis/import-from-mode.js"></script> --> | ||
<!-- <script type="module" src="./js/index.js"></script> --> | ||
<script type="module" src="./index.js"></script> | ||
</body> | ||
</html> |
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,73 @@ | ||
import muze from "@viz/muze"; | ||
import "@viz/muze/muze.css"; | ||
|
||
const loadData = async function ({ | ||
dataSetLink = "/data/cars.json", | ||
schemaLink = "/data/cars-schema.json", | ||
}) { | ||
let data = await fetch(dataSetLink).then((d) => | ||
dataSetLink.split(".").pop() === "csv" ? d.text() : d.json() | ||
); | ||
let schema = await fetch(schemaLink).then((d) => d.json()); | ||
|
||
return { schema, data }; | ||
}; | ||
|
||
let { schema, data } = await loadData({ | ||
dataSetLink: "/data/mn_mv/new_data.csv", | ||
schemaLink: "/data/mn_mv/schema.json", | ||
}); | ||
|
||
const { DataModel } = muze; | ||
const env = muze(); | ||
console.log("Hi"); | ||
|
||
const formattedData = DataModel.loadDataSync(data, schema); | ||
let rootData = new DataModel(formattedData); | ||
|
||
rootData = rootData.select({ | ||
operator: "and", | ||
conditions: [ | ||
{ | ||
field: "region", | ||
value: ["Central", "East"], | ||
operator: "in", | ||
}, | ||
// { | ||
// field: "Measure Names", | ||
// value: ["quantity", "profit"], | ||
// operator: "in", | ||
// }, | ||
{ | ||
field: "ship_mode", | ||
value: ["First Class", "Second Class"], | ||
operator: "in", | ||
}, | ||
{ | ||
field: "segment", | ||
value: ["Consumer", "Corporate"], | ||
operator: "in", | ||
}, | ||
], | ||
}); | ||
|
||
window.canvas = env | ||
.canvas() | ||
.data(rootData) | ||
.width(900) | ||
.height(600) | ||
.rows([["Measure Names", "region", "ship_mode"]]) | ||
.columns([["region", "category"]]) | ||
// .detail(["category"]) | ||
.layers([ | ||
{ | ||
mark: "text", | ||
encoding: { | ||
text: "Measure Values", | ||
color: "sales", | ||
}, | ||
}, | ||
]) | ||
.mount("#chart"); | ||
|
||
// console.log(window.canvas); |
Oops, something went wrong.