-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from chartshq/migrate
Add chart demos
- Loading branch information
Showing
28 changed files
with
6,191 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class CanvasInteractive extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas rows={['Miles_per_Gallon']} columns={['Cylinders']} crossInteractive /> | ||
<Canvas rows={['Miles_per_Gallon']} columns={['Origin']} /> | ||
<Canvas rows={['Acceleration']} columns={['Cylinders']} crossInteractive /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default CanvasInteractive; |
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,41 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class MuzeInteractive extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm} crossInteractive> | ||
<Canvas rows={['Miles_per_Gallon']} columns={['Cylinders']} /> | ||
<Canvas rows={['Horsepower']} columns={['Cylinders']} /> | ||
<Canvas rows={['Acceleration']} columns={['Cylinders']} /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default MuzeInteractive; |
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,42 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
import { Axes } from "@chartshq/react-muze/configurations"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
const axesConfig = Axes.LinearAxis.config().padding(0.2).create(); | ||
|
||
class AxisPadding extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas rows={['Acceleration']} columns={['Cylinders']} xAxis={axesConfig} /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default AxisPadding; |
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,39 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class AxisPosition extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas rows={[[], ['Acceleration']]} columns={['Year']} /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default AxisPosition; |
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,76 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
import { Border } from "@chartshq/react-muze/configurations"; | ||
import { MuzeConstants } from "@chartshq/react-muze/constants"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/coffee.csv") | ||
.then((d) => d.text()); | ||
const schema = [ | ||
{ | ||
"name": "Market", | ||
"type": "dimension" | ||
}, | ||
{ | ||
"name": "Product Type", | ||
"type": "dimension" | ||
}, | ||
{ | ||
"name": "Revenue", | ||
"type": "measure", | ||
"format": val => `$${val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}` | ||
}, | ||
{ | ||
"name": "Expense", | ||
"type": "measure", | ||
"format": val => `$${val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}` | ||
}, | ||
{ | ||
"name": "Profit", | ||
"type": "measure" | ||
} | ||
]; | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
const border = Border.config() | ||
.showRowBorders({ top: true, bottom: true, left: true, right: true }) | ||
.showColBorders({ top: true, bottom: true, left: true, right: true }) | ||
.showValueBorders({ top: false, bottom: false, left: false, right: false }) | ||
.width(1) | ||
.style(MuzeConstants.BORDER_STYLE.DASHED) | ||
.color("#a2a2a2") | ||
.create(); | ||
|
||
class BorderConfig extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas | ||
rows={['Market', 'Product Type']} | ||
columns={[['Revenue', 'Expense'], ['Revenue', 'Expense']]} | ||
border={border} | ||
/> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default BorderConfig; |
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,40 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class ColorScheme extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm} colorScheme={['#00876C', '#E88E63', 'magenta']}> | ||
<Canvas rows={['Acceleration']} columns={['Cylinders']} color="Origin" /> | ||
<Canvas rows={['Acceleration']} columns={['Year']} color="Origin" /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default ColorScheme; |
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,44 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas, Layer } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars-with-null.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class ConnectNullDataChart extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas rows={['Acceleration']} columns={['Year']} color="Origin"> | ||
<Layer mark='line' /> | ||
</Canvas> | ||
<Canvas rows={['Acceleration']} columns={['Year']} color="Origin"> | ||
<Layer mark='line' connectNullData /> | ||
</Canvas> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default ConnectNullDataChart; |
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,40 @@ | ||
import * as React from "react"; | ||
import Muze, { Canvas } from "@chartshq/react-muze/components"; | ||
|
||
async function createDataModel() { | ||
const data = await fetch("/data/cars.json") | ||
.then((d) => d.json()); | ||
const schema = await fetch("/data/cars-schema.json") | ||
.then((d) => d.json()); | ||
const DataModelClass = await Muze.DataModel.onReady(); | ||
const formattedData = await DataModelClass.loadData(data, schema); | ||
return new DataModelClass(formattedData); | ||
} | ||
|
||
class BasicChart extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
dm: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
createDataModel().then((dm) => { | ||
this.setState({ dm }); | ||
}); | ||
} | ||
|
||
render() { | ||
const { dm } = this.state; | ||
|
||
return ( | ||
<Muze data={dm}> | ||
<Canvas rows={['Acceleration']} columns={['Origin']} /> | ||
<Canvas rows={['Acceleration']} columns={['Year']} /> | ||
</Muze> | ||
); | ||
} | ||
} | ||
|
||
export default BasicChart; |
Oops, something went wrong.