Download web/Vchart/pie/chart_0020_pie.html from chartact-benchmark/ChartAct: direct link, hf CLI and curl.
- Browser
- Download file 3.32 kB
-
https://huggingface.co/datasets/chartact-benchmark/ChartAct/resolve/main/web/Vchart/pie/chart_0020_pie.html
- Command line
-
hf download hf://datasets/chartact-benchmark/ChartAct/web/Vchart/pie/chart_0020_pie.html
-
curl -L -o chart_0020_pie.html https://huggingface.co/datasets/chartact-benchmark/ChartAct/resolve/main/web/Vchart/pie/chart_0020_pie.html
3.32 kB
| <div id="chart" style="width:100%;height:520px;"></div> | |
| <script src="_deps/cdn.jsdelivr.net/npm/@visactor/vchart/build/index.min.js"></script> | |
| <script type="module"> | |
| // 这里粘贴你的那段 JS 代码 | |
| const spec = { | |
| type: 'pie', | |
| data: [ | |
| { | |
| id: 'id0', | |
| values: [ | |
| { type: 'oxygen', value: '46.60' }, | |
| { type: 'silicon', value: '27.72' }, | |
| { type: 'aluminum', value: '8.13' }, | |
| { type: 'iron', value: '5' }, | |
| { type: 'calcium', value: '3.63' }, | |
| { type: 'sodium', value: '2.83' }, | |
| { type: 'potassium', value: '2.59' }, | |
| { type: 'others', value: '3.5' } | |
| ] | |
| } | |
| ], | |
| outerRadius: 0.8, | |
| innerRadius: 0.5, | |
| padAngle: 0.6, | |
| valueField: 'value', | |
| categoryField: 'type', | |
| pie: { | |
| style: { | |
| stroke: (datum, chart) => { | |
| return [chart.globalScale('color', datum.type), false, false, false]; | |
| }, | |
| lineWidth: 0, | |
| strokeOpacity: 0.5 | |
| }, | |
| state: { | |
| cutomizedLegendHover: { | |
| lineWidth: 20, | |
| outerBorder: { | |
| visible: true, | |
| distance: 0.5, | |
| stroke: '#fff' | |
| } | |
| }, | |
| hover: { | |
| lineWidth: 20, | |
| outerBorder: { | |
| visible: true, | |
| distance: 0.5, | |
| stroke: '#fff' | |
| } | |
| }, | |
| selected: { | |
| lineWidth: 20, | |
| outerBorder: { | |
| visible: true, | |
| distance: 0.5, | |
| stroke: '#fff' | |
| } | |
| } | |
| } | |
| }, | |
| title: { | |
| visible: true, | |
| text: 'Statistics of Surface Element Content' | |
| }, | |
| legends: { | |
| visible: true, | |
| orient: 'left' | |
| }, | |
| label: { | |
| visible: true, | |
| layout: { | |
| strategy: 'priority', | |
| tangentConstraint: false | |
| }, | |
| position: 'inside' | |
| }, | |
| tooltip: { | |
| mark: { | |
| content: [ | |
| { | |
| key: datum => datum['type'], | |
| value: datum => datum['value'] + '%' | |
| } | |
| ] | |
| } | |
| }, | |
| indicator: { | |
| visible: true, | |
| trigger: 'select', | |
| title: { | |
| visible: true, | |
| style: { | |
| fontSize: 18, | |
| text: data => { | |
| if (data) { | |
| const value = data['type']; | |
| return value ? value : null; | |
| } | |
| return '总和'; | |
| } | |
| } | |
| }, | |
| content: [ | |
| { | |
| visible: true, | |
| style: { | |
| fontSize: 18, | |
| text: data => { | |
| if (data) { | |
| const value = data['value']; | |
| return value ? `${value}%` : null; | |
| } | |
| return 1234; | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| }; | |
| const vchart = new VChart.default(spec, { dom: "chart" }); | |
| vchart.renderSync(); | |
| const firstType = spec.data[0].values[0].type; | |
| if (firstType) { | |
| vchart.updateState({ | |
| cutomizedLegendHover: { | |
| filter: datum => datum.type === firstType | |
| } | |
| }); | |
| } | |
| vchart.on('legendItemHover', e => { | |
| const activeId = e && e.value && e.value.data && e.value.data.id; | |
| if (activeId) { | |
| vchart.updateState({ | |
| cutomizedLegendHover: { | |
| filter: datum => datum.type === activeId | |
| } | |
| }); | |
| } | |
| }); | |
| vchart.on('legendItemUnHover', e => { | |
| vchart.updateState({ | |
| cutomizedLegendHover: { | |
| filter: datum => false | |
| } | |
| }); | |
| }); | |
| // Just for the convenience of console debugging, DO NOT COPY! | |
| window['vchart'] = vchart; | |
| // 只要记得:dom 要写成 "chart" | |
| </script> | |