Posts

Showing posts from August, 2018

bizcharts example: Line Chart

Image
Chart UI Codes ChartComponent.js import React, { Component } from 'react'; import {Chart, Axis, Tooltip, Geom, Coord, Label} from 'bizcharts'; import DataSet from '@antv/data-set'; const { DataView } = DataSet; export class LineChart extends Component { render() { const { data, width, height } = this.props; if (!data || data.length <= 0) return null; const ytitle = { autoRotate: true, offset: -10, textStyle: { fontSize: '22', textAlign: 'left', fill: 'rgb(75,83,87)', rotate: 0 }, position: 'end', }; const xtitle = { autoRotate: true, offset: -20, textStyle: { fontSize: '22', textAlign: 'center', fill: 'rgb(75,83,87)', rotate: 0 }, position: 'end', }; const line = { stroke: 'rgb(197,197,200)', lineWidth: 2

bizcharts example : Doughnut Chart

Image
Chart UI key codes explaintion: <Coord type='theta' innerRadius={0.45} /> without 'innerRadius={0.45}', UI will looks like: without below codes, UI will looks like: <Geom select={[false,{}]} type='intervalStack' position='percent'  color={['type', ['rgba(255, 255, 255, 0)']]}  style={{stroke: 'rgba(152,191,182,1)', lineWidth: 1}}>  </Geom> Codes ChartComponent.js import React, { Component } from 'react'; import {Chart, Axis, Tooltip, Geom, Coord, Label} from 'bizcharts'; import DataSet from '@antv/data-set'; const { DataView } = DataSet; export class ScoreChart extends Component { render() { const { width, height, score } = this.props; const scoreData = [ { type: 'Score', value: score }, { type: '', value: 10 - score }, ]; const scoreDv = new DataView(); scoreDv.source(scoreData) .transform({ type: 'pe

sed replace shell variable which include slash ('/')

Test content cat test-sed.txt aaa/bbb/ccc/ddd/eee fff/ggg/ss replace "ccc/ddd" to "CCC/DDD" via sed NEW_STRING="CCC/DDD" sed -i "s:ccc/ddd:${NEW_STRING}:" test-sed.txt Notes: use ':' as seperate char rather than '/', which is default use "" include the replace command

Await is a reserved word error

Solution: In order to use await, the function directly enclosing it needs to be async. example codes: async tryGetUserName() { let session = await Auth.currentSession(); ...... } async should be there, otherwise you will get the error.