import { registerShape, Chart, Axis, Tooltip, Coord, Point, Guide, Series } from 'viser-react'; import * as React from 'react'; registerShape('point', 'pointer', { draw(cfg, container) { let point = cfg.points[0]; // 获取第一个标记点 point = this.parsePoint(point); const center = this.parsePoint({ // 获取极坐标系下画布中心点 x: 0, y: 0 }); // 绘制指针 container.addShape('line', { attrs: { x1: center.x, y1: center.y, x2: point.x, y2: point.y + 15, stroke: cfg.color, lineWidth: 5, lineCap: 'round' } }); return container.addShape('circle', { attrs: { x: center.x, y: center.y, r: 9.75, stroke: cfg.color, lineWidth: 4.5, fill: '#fff' } }); } }); const scale = [{ dataKey: 'value', min: 0, max: 9, ticks: [2.25, 3.75, 5.25, 6.75], nice: false }]; const data = [ { value: 6 } ]; export default class App extends React.Component { render() { return (
{ if (val === '2.25') { return '差'; } else if (val === '3.75') { return '中'; } else if (val === '5.25') { return '良'; } return '优'; }, textStyle: { fontSize: 18, textAlign: 'center' } }} tickLine={null} grid={null} />

合格率

${data[0].value * 10}%

`} /> ); } }