| <div id="chart" style="width:100%;height:520px;"></div> |
| <script src="https://cdn.jsdelivr.net/npm/@visactor/vchart/build/index.min.js"></script> |
| <script type="module"> |
| |
| const data = [ |
| { type: 'oxygen', value: '46.60', formula: 'O', texture: 'circle' }, |
| { type: 'silicon', value: '27.72', formula: 'Si', texture: 'horizontal-line' }, |
| { type: 'aluminum', value: '8.13', formula: 'Al', texture: 'vertical-line' }, |
| { type: 'iron', value: '5', formula: 'Fe', texture: 'rect' }, |
| { type: 'calcium', value: '3.63', formula: 'Ca', texture: 'grid' }, |
| { type: 'sodium', value: '2.83', formula: 'Na', texture: 'bias-rl' }, |
| { type: 'potassium', value: '2.59', formula: 'K', texture: 'diamond' }, |
| { type: 'others', value: '3.5', formula: 'Others', texture: 'bias-lr' } |
| ]; |
| const spec = { |
| type: 'pie', |
| data: [ |
| { |
| id: 'id0', |
| values: data |
| } |
| ], |
| outerRadius: 0.8, |
| innerRadius: 0.5, |
| padAngle: 0.6, |
| valueField: 'value', |
| categoryField: 'type', |
| pie: { |
| style: { |
| cornerRadius: 10, |
| texture: datum => datum['texture'] |
| }, |
| state: { |
| hover: { |
| outerRadius: 0.85, |
| stroke: '#000', |
| lineWidth: 1 |
| }, |
| selected: { |
| outerRadius: 0.85, |
| stroke: '#000', |
| lineWidth: 1 |
| } |
| } |
| }, |
| title: { |
| visible: true, |
| text: 'Statistics of Surface Element Content' |
| }, |
| indicator: { |
| visible: true, |
| trigger: 'hover', |
| limitRatio: 0.5, |
| title: { |
| visible: true, |
| autoFit: true, |
| fitStrategy: 'inscribed', |
| style: { |
| fontWeight: 'bolder', |
| fontFamily: 'Times New Roman', |
| fill: '#888', |
| text: datum => { |
| const d = datum ?? data[0]; |
| return d['formula']; |
| } |
| } |
| }, |
| content: [ |
| { |
| visible: true, |
| autoFit: true, |
| fitStrategy: 'inscribed', |
| style: { |
| fill: 'orange', |
| fontWeight: 'bolder', |
| fontFamily: 'Times New Roman', |
| text: datum => { |
| const d = datum ?? data[0]; |
| return d['type']; |
| } |
| } |
| }, |
| { |
| visible: true, |
| autoFit: true, |
| fitStrategy: 'inscribed', |
| style: { |
| fill: 'orange', |
| fontFamily: 'Times New Roman', |
| text: datum => { |
| const d = datum ?? data[0]; |
| return d['value'] + '%'; |
| } |
| } |
| } |
| ] |
| }, |
| legends: { |
| visible: true, |
| orient: 'left', |
| item: { |
| shape: { |
| style: { |
| symbolType: 'circle', |
| texture: datum => datum['texture'] |
| } |
| } |
| } |
| }, |
| tooltip: { |
| mark: { |
| content: [ |
| { |
| key: datum => datum['type'], |
| value: datum => datum['value'] + '%' |
| } |
| ] |
| } |
| } |
| }; |
| |
| |
| |
| const vchart = new VChart.default(spec, { dom: "chart" }); |
| vchart.renderSync(); |
| |
| |
| window['vchart'] = vchart; |
| |
| </script> |
|
|