import React from 'react'; import ReactDOM from 'react-dom'; import G2 from '@antv/g2'; window.G2 = G2; import Slider from 'bizcharts-slider' import { Chart, Geom, Axis, Tooltip, Coord, Label, Legend, View, Guide, Shape } from 'bizcharts'; import DataSet from '@antv/data-set'; import data from './data/candle-sticks.json'; const { Line, Region } = Guide; const cols = { 'time': { type: 'timeCat', nice: false, range: [ 0, 1 ] }, trend: { values: [ '上涨', '下跌' ] }, 'volumn': {alias: '成交量'}, 'start': {alias: '开盘价'}, 'end': {alias: '收盘价'}, 'max': {alias: '最高价'}, 'min': {alias: '最低价'}, 'range': {alias: '股票价格'} } const ds = new DataSet({ state: { start: '2015-04-07', end: '2015-07-28' } }); const dv = ds.createView(); dv.source(data) .transform({ type: 'filter', callback: obj => { const date = obj.time; return date <= ds.state.end && date >= ds.state.start; } }) .transform({ type: 'map', callback: obj => { obj.trend = (obj.start <= obj.end) ? '上涨' : '下跌'; obj.range = [ obj.start, obj.end, obj.max, obj.min ]; return obj; } }); export default class SliderGuide extends React.Component { constructor() { super(); this.state = { start: ds.state.start, end: ds.state.end } } onChange = (obj) => { const { startText, endText} = obj; ds.setState('start', startText); ds.setState('end', endText); this.setState({ start: startText, end: endText }); } render() { return (