Skip to content

Commit

Permalink
add demos
Browse files Browse the repository at this point in the history
  • Loading branch information
hm.hm committed Dec 20, 2017
1 parent 35b778e commit 3b30188
Show file tree
Hide file tree
Showing 25 changed files with 42,935 additions and 29 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build/
demo/
testDemo/
doc/
es6/
node_modules/
Expand Down
3 changes: 1 addition & 2 deletions demo/component/com16/guide.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { Component } from 'react';
import { Com16 } from 'bizcharts';
import { Chart, Geom, Legend, Tooltip, Axis, Guide } from 'bizcharts';
import DataSet from '@antv/data-set';
import data from '../../data/heatmap.json'

const { Chart, Geom, Legend, Tooltip, Axis, Guide } = Com16;
const { Image } = Guide;

const { DataView } = DataSet;
Expand Down
4 changes: 2 additions & 2 deletions demo/component/com16/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export default class LineChart extends Component {
return (
<div className='line-charts'>
<div className='line-chart-basic'>
{/* <Basic />
<Basic />
<ViewChart />
<GuideChart /> */}
<GuideChart />
<ListFacet />
</div>
</div>
Expand Down
17 changes: 10 additions & 7 deletions demo/component/com16/view.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { Component } from 'react';
import { Com16 } from 'bizcharts';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';
import DataSet from '@antv/data-set';

const { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } = Com16;

const { DataView } = DataSet;

const data = [
Expand Down Expand Up @@ -42,16 +40,18 @@ export default class PieC extends Component {
constructor(props) {
super(props);
this.state = {
showLabel: false,
showLabel: true,
lineWidth : 1,
showView: true,
};
}

componentDidMount() {
setTimeout(() => {
this.setState({
showLabel: true,
showLabel: false,
lineWidth: 15,
showView: true,
});
}, 2000);
}
Expand All @@ -78,10 +78,13 @@ export default class PieC extends Component {
style={{lineWidth: 1,stroke: '#fff'}}
select={false}
>
<Label content='type' offset={-10} />
{/* {
this.state.showLabel ? <Label content='type' offset={-10} /> : null
} */}

</Geom>
{
this.state.showLabel ?
this.state.showView ?
<View data={dv1} scale={cols} >
<Coord type='theta' radius={0.75} innerRadius={0.5 / 0.75}/>
<Geom
Expand Down
21 changes: 10 additions & 11 deletions demo/component/guage/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,22 @@ export default class Basic extends Component {
/>
<Guide >
<Arc zIndex={0} start={[ 0, 0.965 ]} end={[ 9, 0.965 ]}
style={{ // 底灰色
stroke: '#000',
lineWidth: 18,
opacity: 0.09
}}/>
</Guide>
<Guide >
style={{ // 底灰色
stroke: '#000',
lineWidth: 18,
opacity: 0.09
}}/>
<Arc zIndex={1} start={[ 0, 0.965 ]} end={[ data[0].value, 0.965 ]}
style={{ // 底灰色
stroke: '#1890FF',
style={{ // 底灰色
stroke: '#1890FF',
lineWidth: 18,
}} />
}}
/>
<Html
position={[ '50%', '95%' ]}
html={() => {return ('<div style="width: 300px;text-align: center;font-size: 12px!important;"><p style="font-size: 1.75em; color: rgba(0,0,0,0.43);margin: 0;">合格率</p><p style="font-size: 3em;color: rgba(0,0,0,0.85);margin: 0;">'+ data[0].value * 10+'%</p></div>')}}
/>
</Guide>
</Guide>
<Geom type="point" position="value*1" shape='pointer' color='#1890FF'
active={false}
style={{stroke: '#fff',lineWidth: 1}}
Expand Down
2 changes: 1 addition & 1 deletion demo/component/guage/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class Color extends Component {
}}
/>
<Guide>
<Arc zIndex={0} start={[ 0, 0.965 ]} end={[ 6, 0.965 ]} vvv={val}
<Arc zIndex={0} start={[ 0, 0.965 ]} end={[ 6, 0.965 ]}
style={{ // 底灰色
stroke: 'rgba(0, 0, 0, 0.09)',
lineWidth
Expand Down
2 changes: 1 addition & 1 deletion demo/component/guage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class GuageChart extends Component {
return (
<div className='guage'>
<div className='guage-basic'>
{/* <Basic /> */}
<Basic />
<Color />
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions demo/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import Relation from './relation';
import Facet from './facet';
import Theme from './theme';
import Map from './map';

import Com16 from './com16';
import Guage from './guage';

export default {
lineChart: {
Line,
Bar,
Com16,
Area,
Point,
Pie,
Expand All @@ -26,5 +24,6 @@ export default {
Relation,
Facet,
Theme,
Guage,
},
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +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",
"test": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"lint": "eslint src",
"autofix": "eslint src --fix",
Expand All @@ -57,8 +58,7 @@
"@antv/g2": "3.0.0",
"invariant": "^2.2.2",
"warning": "^3.0.0",
"prop-types": "^15.6.0",
"interface-es6": "1.0.1"
"prop-types": "^15.6.0"
},
"devDependencies": {
"@antv/data-set": "0.6.2",
Expand Down
10 changes: 10 additions & 0 deletions testDemo/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
plugins: [
"transform-export-extensions",
"transform-decorators-legacy",
"transform-class-properties",
"transform-object-rest-spread",
"transform-function-bind",
],
presets: ["es2015", "react"]
}
150 changes: 150 additions & 0 deletions testDemo/component/guide/adddelete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import React, { Component } from 'react';
import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts';

const { Text, Html, Arc } = Guide;

function creatData(d) {
const data = [];
let val = Math.random() * 6;
val = val.toFixed(1);
if (!d) {
data.push({value: val * 1});
} else {
data.push({value: d});
}

return data;
}

// 自定义Shape 部分
Shape.registerShape('point', 'pointer', {
drawShape(cfg, group) {
let point = cfg.points[0]; // 获取第一个标记点
point = this.parsePoint(point);
const center = this.parsePoint({ // 获取极坐标系下画布中心点
x: 0,
y: 0
});
// 绘制指针
group.addShape('line', {
attrs: {
x1: center.x,
y1: center.y,
x2: point.x,
y2: point.y - 20,
stroke: cfg.color,
lineWidth: 5,
lineCap: 'round'
}
});
return group.addShape('circle', {
attrs: {
x: center.x,
y: center.y,
r: 12,
stroke: cfg.color,
lineWidth: 4.5,
fill: '#fff'
}
});
}
});

const color = ['#0086FA', '#FFBF00', '#F5222D'];
const cols = {
'value': {
min: 0,
max: 6,
tickInterval: 1,
nice: false
}
}

export default class Color extends Component {
constructor() {
super();
this.state = {
data: creatData(),
lineWidth: 25,
}
}
componentDidMount() {
const self = this;
setInterval(function(){
const data=creatData();
self.setState({
data:data
})
}, 1000);
}

render() {
const { data, lineWidth } = this.state;
const val = data[0].value;
return (
<Chart height={window.innerHeight} data={this.state.data} scale={cols} padding={[ 0, 0, 200, 0 ]} forceFit>
<Coord type='polar' startAngle={-9 / 8 * Math.PI} endAngle={1 / 8 * Math.PI} radius={0.75} />
<Axis name='value'
zIndex={2}
label={{
offset: -20,
textStyle: {
fontSize: 18,
fill: '#CBCBCB',
textAlign: 'center',
textBaseline: 'middle'
}}}
tickLine={{
length: -24,
stroke: '#fff',
strokeOpacity: 1
}}
/>
<Guide>
<Arc zIndex={0} start={[ 0, 0.965 ]} end={[ 6, 0.965 ]} vvv={val}
style={{ // 底灰色
stroke: 'rgba(0, 0, 0, 0.09)',
lineWidth
}} />
{ val>=2 && <Arc zIndex={1} start={[ 0, 0.965 ]} end={[val, 0.965 ]}
style={{ // 底灰色
stroke: color[0],
lineWidth
}} />}
{ val>=4 && <Arc zIndex={1} start={[ 2, 0.965 ]} end={[4, 0.965 ]}
style={{ // 底灰色
stroke: color[1],
lineWidth
}} />}
{ val>=4 && val<6 && <Arc zIndex={1} start={[ 4, 0.965 ]} end={[val, 0.965 ]}
style={{ // 底灰色
stroke: color[2],
lineWidth
}} />}
{ val>=2 && val<4 && <Arc zIndex={1} start={[ 2, 0.965 ]} end={[val, 0.965 ]}
style={{ // 底灰色
stroke: color[1],
lineWidth
}} />}
{ val<2 && <Arc zIndex={1} start={[ 0, 0.965 ]} end={[val, 0.965 ]}
style={{ // 底灰色
stroke: color[0],
lineWidth
}} />}
<Html
position={[ '50%', '95%' ]}
html={() => {return ('<div style="width: 300px;text-align: center;font-size: 12px!important;"><p style="font-size: 1.75em; color: rgba(0,0,0,0.43);margin: 0;">合格率</p><p style="font-size: 3em;color: rgba(0,0,0,0.85);margin: 0;">'+ val * 10+'%</p></div>')}}
/>
</Guide>
<Geom
type="point"
position="value*1"
shape='pointer'
color='#1890FF'
active={false}
style={{stroke: '#fff',lineWidth: 1}}
/>
</Chart>
);
}
}
15 changes: 15 additions & 0 deletions testDemo/component/guide/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, { Component } from 'react';
import AddDelete from './adddelete';
import Update from './update';


export default class Guide extends Component {
render() {
return (
<div>
<AddDelete />
<Update />
</div>
);
}
}
Loading

0 comments on commit 3b30188

Please sign in to comment.