Skip to content

Commit

Permalink
添加coord测试文件
Browse files Browse the repository at this point in the history
  • Loading branch information
BambooSword committed Dec 21, 2017
1 parent 7162bf8 commit 2635c5c
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"no-lonely-if" : "off",
"class-methods-use-this" : "off",
"no-restricted-syntax" : "off",
"no-param-reassign" : "off"
"no-param-reassign" : "off",
"linebreak-style" : "off"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build-umd": "cross-env NODE_ENV=development webpack src/index.jsx build/BizCharts.js",
"build-min": "cross-env NODE_ENV=production webpack src/index.jsx build/BizCharts.min.js",
"demo": "webpack-dev-server --progress --port 3510 --content-base demo --inline --config demo/webpack.config.js",
"testDemo": "webpack-dev-server --progress --port 4000 --content-base testDemo --inline --config testDemo/webpack.config.js",
"testDemo": "webpack-dev-server --progress --port 9000 --content-base testDemo --inline --config testDemo/webpack.config.js",
"test": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"lint": "eslint src",
"autofix": "eslint src --fix",
Expand Down
61 changes: 61 additions & 0 deletions testDemo/component/coord/adddelete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { DataView } = DataSet;
const { Text, Html, Arc, Line } = Guide;
const data1 = [
{ year: '1951 年', sales: 38 },
{ year: '1952 年', sales: 52 },
{ year: '1956 年', sales: 61 },
{ year: '1957 年', sales: 145 },
{ year: '1958 年', sales: 48 },
{ year: '1959 年', sales: 38 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 38 },
];
const data2 = [
{ year: '1951 年', sales: 28 },
{ year: '1952 年', sales: 62 },
{ year: '1956 年', sales: 31 },
{ year: '1957 年', sales: 105 },
{ year: '1958 年', sales: 148 },
{ year: '1959 年', sales: 8 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 98 },
];
const cols = {
'sales': {tickInterval: 20},
};
const type = ['rect','helix','polar','theta']
export default class Basic extends Component {
constructor() {
super();
this.state = {
data: data1,
type: 'rect'
}
}

componentDidMount() {
setInterval(() => {
this.setState({
data: this.state.data == data1 ? data2 : data1,
type: type[Math.floor(Math.random()*5)]
});
}, 1000);
}
render() {
return (
<Chart height={400} data={this.state.data} scale={cols} forceFit>
<Coord
type={this.state.type}
/>
<Axis name="year" />
<Axis name="value" />
<Tooltip crosshairs={{type : "y"}}/>
<Geom type="interval" position="year*sales" />
</Chart>
);
}
}
21 changes: 21 additions & 0 deletions testDemo/component/coord/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Component } from 'react';
import AddDelete from './adddelete';
import UpdatePolar from './updatePolar';
import UpdateHelix from './updateHelix';
import UpdateRect from './updateRect';
import UpdateTheta from './updateTheta';


export default class Guide extends Component {
render() {
return (
<div>
<AddDelete />
<UpdateHelix />
<UpdatePolar />
<UpdateRect />
<UpdateTheta />
</div>
);
}
}
67 changes: 67 additions & 0 deletions testDemo/component/coord/updateHelix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { DataView } = DataSet;
const { Text, Html, Arc, Line } = Guide;
const data = [
{ year: '1951 年', sales: 38 },
{ year: '1952 年', sales: 52 },
{ year: '1956 年', sales: 61 },
{ year: '1957 年', sales: 145 },
{ year: '1958 年', sales: 48 },
{ year: '1959 年', sales: 38 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 38 },
];
const cols = {
'sales': {tickInterval: 20},
};
export default class Basic extends Component {
constructor() {
super();
this.state = {
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
}
}

componentDidMount() {
setInterval(() => {
this.setState({
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:this.state.reflect='x'? 'y':'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
});
}, 1000);
}
render() {
return (
<Chart height={400} data={data} scale={cols} forceFit>
<Coord
type="helix"
rotate={this.state.rotate}
scale ={this.state.scale}
reflect={this.state.reflect}
startAngle={this.state.startAngle}
endAngle={this.state.endAngle}
innerRadius={this.state.innerRadius}
radius={this.state.radius}
/>
<Axis name="year" />
<Axis name="value" />
<Tooltip crosshairs={{type : "y"}}/>
<Geom type="interval" position="year*sales" />
</Chart>
);
}
}
67 changes: 67 additions & 0 deletions testDemo/component/coord/updatePolar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { DataView } = DataSet;
const { Text, Html, Arc, Line } = Guide;
const data = [
{ year: '1951 年', sales: 38 },
{ year: '1952 年', sales: 52 },
{ year: '1956 年', sales: 61 },
{ year: '1957 年', sales: 145 },
{ year: '1958 年', sales: 48 },
{ year: '1959 年', sales: 38 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 38 },
];
const cols = {
'sales': {tickInterval: 20},
};
export default class Basic extends Component {
constructor() {
super();
this.state = {
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
}
}

componentDidMount() {
setInterval(() => {
this.setState({
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:this.state.reflect='x'? 'y':'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
});
}, 1000);
}
render() {
return (
<Chart height={400} data={data} scale={cols} forceFit>
<Coord
type="polar"
rotate={this.state.rotate}
scale ={this.state.scale}
reflect={this.state.reflect}
startAngle={this.state.startAngle}
endAngle={this.state.endAngle}
innerRadius={this.state.innerRadius}
radius={this.state.radius}
/>
<Axis name="year" />
<Axis name="value" />
<Tooltip crosshairs={{type : "y"}}/>
<Geom type="interval" position="year*sales" />
</Chart>
);
}
}
63 changes: 63 additions & 0 deletions testDemo/component/coord/updateRect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { DataView } = DataSet;
const { Text, Html, Arc, Line } = Guide;
const data = [
{ year: '1951 年', sales: 38 },
{ year: '1952 年', sales: 52 },
{ year: '1956 年', sales: 61 },
{ year: '1957 年', sales: 145 },
{ year: '1958 年', sales: 48 },
{ year: '1959 年', sales: 38 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 38 },
];
const cols = {
'sales': {tickInterval: 20},
};
export default class Basic extends Component {
constructor() {
super();
this.state = {
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
}
}

componentDidMount() {
setInterval(() => {
this.setState({
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:this.state.reflect='x'? 'y':'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
});
}, 1000);
}
render() {
return (
<Chart height={400} data={data} scale={cols} forceFit>
<Coord
type="rect"
rotate={this.state.rotate}
scale ={this.state.scale}
reflect={this.state.reflect}
/>
<Axis name="year" />
<Axis name="value" />
<Tooltip crosshairs={{type : "y"}}/>
<Geom type="interval" position="year*sales" />
</Chart>
);
}
}
67 changes: 67 additions & 0 deletions testDemo/component/coord/updateTheta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { DataView } = DataSet;
const { Text, Html, Arc, Line } = Guide;
const data = [
{ year: '1951 年', sales: 38 },
{ year: '1952 年', sales: 52 },
{ year: '1956 年', sales: 61 },
{ year: '1957 年', sales: 145 },
{ year: '1958 年', sales: 48 },
{ year: '1959 年', sales: 38 },
{ year: '1960 年', sales: 38 },
{ year: '1962 年', sales: 38 },
];
const cols = {
'sales': {tickInterval: 20},
};
export default class Basic extends Component {
constructor() {
super();
this.state = {
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
}
}

componentDidMount() {
setInterval(() => {
this.setState({
rotate: Math.random() * 360,
scale: [Math.random() *0.5+0.5,Math.random() *0.5+0.5],
reflect:this.state.reflect='x'? 'y':'x',
innerRadius: Math.random(),
radius: Math.random(),
startAngle:Math.random()-1 * Math.PI,
endAngle:Math.random() * Math.PI
});
}, 1000);
}
render() {
return (
<Chart height={400} data={data} scale={cols} forceFit>
<Coord
type="theta"
rotate={this.state.rotate}
scale ={this.state.scale}
reflect={this.state.reflect}
startAngle={this.state.startAngle}
endAngle={this.state.endAngle}
innerRadius={this.state.innerRadius}
radius={this.state.radius}
/>
<Axis name="year" />
<Axis name="value" />
<Tooltip crosshairs={{type : "y"}}/>
<Geom type="interval" position="year*sales" />
</Chart>
);
}
}
2 changes: 2 additions & 0 deletions testDemo/component/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Guide from './guide';
import Coord from './coord';

export default {
Demos: {
Guide,
Coord
},
};

0 comments on commit 2635c5c

Please sign in to comment.