|
| 1 | +--- |
| 2 | +category: examples |
| 3 | +group: pictogram chart |
| 4 | +title: SVG Beef Cuts |
| 5 | +keywords: pictogramChart, space |
| 6 | +order: 26-1 |
| 7 | +cover: /vchart/preview/pictogram-cow_1.13.0.png |
| 8 | +option: pictogramChart |
| 9 | +--- |
| 10 | + |
| 11 | +# SVG Beef Cuts |
| 12 | + |
| 13 | +> Demo is a replica of the echarts-Beef Cuts example. |
| 14 | +
|
| 15 | +## Key Configurations |
| 16 | + |
| 17 | +- In the SVG file, configure the name attribute for the pictogram, then you can specify the pictogram style through the name configuration in the chart settings; |
| 18 | + |
| 19 | +## Code Demo |
| 20 | + |
| 21 | +```javascript livedemo |
| 22 | +/** --Add the following code when using in business context-- */ |
| 23 | +// When using in business context, please additionally import |
| 24 | +// import { registerPictogramChart } from '@visactor/vchart'; |
| 25 | +// registerPictogramChart(); |
| 26 | +/** --Add the above code when using in business context-- */ |
| 27 | +VCHART_MODULE.registerPictogramChart(); |
| 28 | +/** --Delete the above code when using in business context-- */ |
| 29 | + |
| 30 | +const response = await fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/pictogram/cow.svg'); |
| 31 | +const cow = await response.text(); |
| 32 | + |
| 33 | +const spec = { |
| 34 | + type: 'pictogram', |
| 35 | + data: { |
| 36 | + id: 'data', |
| 37 | + values: [ |
| 38 | + { name: 'Queue', value: 15 }, |
| 39 | + { name: 'Langue', value: 35 }, |
| 40 | + { name: 'Plat de joue', value: 15 }, |
| 41 | + { name: 'Gros bout de poitrine', value: 25 }, |
| 42 | + { name: 'Jumeau à pot-au-feu', value: 45 }, |
| 43 | + { name: 'Onglet', value: 85 }, |
| 44 | + { name: 'Plat de tranche', value: 25 }, |
| 45 | + { name: 'Araignée', value: 15 }, |
| 46 | + { name: 'Gîte à la noix', value: 55 }, |
| 47 | + { name: "Bavette d'aloyau", value: 25 }, |
| 48 | + { name: 'Tende de tranche', value: 65 }, |
| 49 | + { name: 'Rond de gîte', value: 45 }, |
| 50 | + { name: 'Bavettede de flanchet', value: 85 }, |
| 51 | + { name: 'Flanchet', value: 35 }, |
| 52 | + { name: 'Hampe', value: 75 }, |
| 53 | + { name: 'Plat de côtes', value: 65 }, |
| 54 | + { name: 'Tendron Milieu de poitrine', value: 65 }, |
| 55 | + { name: 'Macreuse à pot-au-feu', value: 85 }, |
| 56 | + { name: 'Rumsteck', value: 75 }, |
| 57 | + { name: 'Faux-filet', value: 65 }, |
| 58 | + { name: 'Côtes Entrecôtes', value: 55 }, |
| 59 | + { name: 'Basses côtes', value: 45 }, |
| 60 | + { name: 'Collier', value: 85 }, |
| 61 | + { name: 'Jumeau à biftek', value: 15 }, |
| 62 | + { name: 'Paleron', value: 65 }, |
| 63 | + { name: 'Macreuse à bifteck', value: 45 }, |
| 64 | + { name: 'Gîte', value: 85 }, |
| 65 | + { name: 'Aiguillette baronne', value: 65 }, |
| 66 | + { name: 'Filet', value: 95 } |
| 67 | + ] |
| 68 | + }, |
| 69 | + nameField: 'name', |
| 70 | + valueField: 'value', |
| 71 | + color: { |
| 72 | + type: 'linear', |
| 73 | + domain: [ |
| 74 | + { |
| 75 | + dataId: 'data', |
| 76 | + fields: ['value'] |
| 77 | + } |
| 78 | + ], |
| 79 | + range: ['#f51633', '#921319'] |
| 80 | + }, |
| 81 | + legends: [ |
| 82 | + { |
| 83 | + visible: true, |
| 84 | + type: 'color', |
| 85 | + field: 'value', |
| 86 | + orient: 'top' |
| 87 | + } |
| 88 | + ], |
| 89 | + region: [ |
| 90 | + { |
| 91 | + roam: true |
| 92 | + } |
| 93 | + ], |
| 94 | + svg: 'cow', |
| 95 | + pictogram: { |
| 96 | + style: { |
| 97 | + fill: { |
| 98 | + field: 'value', |
| 99 | + scale: 'color' |
| 100 | + } |
| 101 | + } |
| 102 | + }, |
| 103 | + 'Tendron Milieu de poitrine': { |
| 104 | + style: { |
| 105 | + fill: 'orange' |
| 106 | + }, |
| 107 | + state: { |
| 108 | + hover: { |
| 109 | + fill: '#FFBF7F' |
| 110 | + } |
| 111 | + } |
| 112 | + } |
| 113 | +}; |
| 114 | +VChart.registerSVG('cow', cow); |
| 115 | + |
| 116 | +const vchart = new VChart(spec, { dom: CONTAINER_ID }); |
| 117 | +vchart.renderSync(); |
| 118 | + |
| 119 | +// Just for the convenience of console debugging, DO NOT COPY! |
| 120 | +window['vchart'] = vchart; |
| 121 | +``` |
| 122 | + |
| 123 | +## Related Tutorials |
| 124 | + |
| 125 | +[PictogramChart](link) |
0 commit comments