tiny-vue/examples/sites/demos/apis/chart-wordcloud.js

366 lines
22 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default {
mode: ['pc'],
apis: [
{
name: 'chart-wordcloud',
type: 'component',
options: [
{
name: 'theme',
type: 'string',
defaultValue: 'cloud-light',
typeAnchorName: 'Theme',
desc: {
'zh-CN': '主题',
'en-US': 'Chart theme'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'color',
type: 'array | string',
defaultValue: '随主题',
typeAnchorName: 'Color',
desc: {
'zh-CN': '图表颜色',
'en-US': 'Chart color'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'tooltip',
type: 'object',
defaultValue: '默认显示',
typeAnchorName: 'Tooltip',
desc: {
'zh-CN': '悬浮提示框内容配置',
'en-US': 'Content configuration of floating prompt box'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'data',
type: 'array',
defaultValue: '无',
typeAnchorName: 'Data',
desc: {
'zh-CN': '图表数据',
'en-US': 'Chart data'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'gridSize',
type: 'number',
defaultValue: '16',
typeAnchorName: 'GridSize',
desc: {
'zh-CN': '词云图文本间距',
'en-US': 'Word cloud map text spacing'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'sizeRange',
type: 'array',
defaultValue: '[14, 60]',
typeAnchorName: 'SizeRange',
desc: {
'zh-CN': '字体范围',
'en-US': 'Font Range'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'rotationRange',
type: 'array',
defaultValue: '[0,0]',
typeAnchorName: 'RotationRange',
desc: {
'zh-CN': '文字旋转范围',
'en-US': 'Text rotation range'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'rotationStep',
type: 'number',
defaultValue: '0',
typeAnchorName: 'RotationStep',
desc: {
'zh-CN': '文字旋转步值',
'en-US': 'Text rotation step value'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'shape',
type: 'string',
defaultValue: 'circle',
typeAnchorName: 'Shape',
desc: {
'zh-CN': '词云图形状',
'en-US': 'Word cloud shape'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'width',
type: 'string',
defaultValue: '75%',
typeAnchorName: 'Width',
desc: {
'zh-CN': '词云图宽度',
'en-US': 'Word cloud width'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'height',
type: 'string',
defaultValue: '80%',
typeAnchorName: 'Height',
desc: {
'zh-CN': '词云图高度',
'en-US': 'Word cloud height'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'maskImage',
type: 'string',
defaultValue: '无',
typeAnchorName: 'MaskImage',
desc: {
'zh-CN': '词云图形状图片配置',
'en-US': 'Word cloud shape image configuration'
},
mode: ['pc'],
pcDemo: ''
},
{
name: 'textColor',
type: 'function',
defaultValue: '无',
typeAnchorName: 'TextColor',
desc: {
'zh-CN': '词云图文本颜色',
'en-US': 'Word cloud map text color'
},
mode: ['pc'],
pcDemo: ''
}
],
events: [
{
name: 'ready',
type: '()=>void',
defaultValue: '',
desc: {
'zh-CN': '图表渲染完成后触发,每次渲染都会触发一次',
'en-US': 'Triggered after the completion of chart rendering, it will be triggered once every rendering'
},
mode: ['pc', 'mobile', 'mobile-first'],
pcDemo: '',
mobileDemo: '',
mfDemo: ''
},
{
name: 'ready-once',
type: '()=>void',
defaultValue: '',
desc: {
'zh-CN': '图表渲染完成后触发,只会在首次渲染完成后触发',
'en-US':
'Triggered after the completion of chart rendering, it will only be triggered after the first rendering is completed'
},
mode: ['pc', 'mobile', 'mobile-first'],
pcDemo: '',
mobileDemo: '',
mfDemo: ''
}
],
methods: [],
slots: [
{
name: 'default',
type: '',
defaultValue: '',
desc: {
'zh-CN': '组件默认插槽',
'en-US': 'Component Default Slot'
},
mode: ['pc', 'mobile-first'],
pcDemo: '',
mfDemo: ''
}
]
}
],
types: [
{
name: 'Data',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">格式:</p>
<div data-v-md-line="3"><div class="v-md-pre-wrapper v-md-pre-wrapper-d extra-class"><pre class="v-md-hljs-d"><code> data:[
{
name: <span class="hljs-string">'visualMap'</span>,
value: <span class="hljs-number">122199</span>,
},
{
name: <span class="hljs-string">'continuous'</span>,
value: <span class="hljs-number">10288</span>,
},
{
name: <span class="hljs-string">'contoller'</span>,
value: <span class="hljs-number">620</span>,
},
...
]
</code></pre>
</div></div><p data-v-md-line="21">说明:图表数据 name 为页面节点名称 value 与页面节点大小正相关</p>
</div></div></div></td></tr></div>`
},
{
name: 'GridSize',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>16</code></p>
<p data-v-md-line="3">说明:网格大小 自定义各文本之间距离</p>
</div></div></div></td></tr></div>`
},
{
name: 'Height',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>80%</code></p>
<p data-v-md-line="3">说明:配置词云图形状高度</p>
</div></div></div></td></tr></div>`
},
{
name: 'MaskImage',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">说明:配置词云图的形状图片</p>
</div></div></div></td></tr></div>`
},
{
name: 'RotationRange',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>[0,0]</code></p>
<p data-v-md-line="3">说明:文字旋转角度范围</p>
</div></div></div></td></tr></div>`
},
{
name: 'RotationStep',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>0</code></p>
<p data-v-md-line="3">说明:文字旋转步值 未配置 <code>rotationRange</code> 时 <code>rotationStep</code> 值恒为 0 配置 <code>rotationRange</code> 时 <code>rotationStep</code> 值不得为 0</p>
</div></div></div></td></tr></div>`
},
{
name: 'Shape',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>circle</code>(圆形)</p>
<p data-v-md-line="3">可选值:<code>circle</code>(圆形) , <code>cardioid</code>(心形) , <code>diamond</code>(菱形) , <code>triangle-forward</code>(前三角形) , <code>triangle</code>(三角形) , <code>pentagon</code>(五角形) , <code>star</code>(星形)</p>
<p data-v-md-line="5">说明:配置词云图形状</p>
</div></div></div></td></tr></div>`
},
{
name: 'SizeRange',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>[14,60]</code></p>
<p data-v-md-line="3">说明:字体大小范围</p>
</div></div></div></td></tr></div>`
},
{
name: 'TextColor',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">格式:</p>
<div data-v-md-line="3"><div class="v-md-pre-wrapper v-md-pre-wrapper-d extra-class"><pre class="v-md-hljs-d"><code>textColor: (data) =&gt; {
<span class="hljs-keyword">return</span> <span class="hljs-string">'#191919'</span>;
},
</code></pre>
</div></div><p data-v-md-line="9">说明:自定义词云图每个文本的颜色 若同时定义了属性<code>color</code> 则以<code>textColor</code>为准</p>
</div></div></div></td></tr></div>`
},
{
name: 'Width',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>75%</code></p>
<p data-v-md-line="3">说明:配置词云图形状宽度</p>
</div></div></div></td></tr></div>`
},
{
name: 'Theme',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:<code>light</code></p>
<p data-v-md-line="3">可选值:</p>
<p data-v-md-line="5"><code>light</code> ICT3.0图表浅色主题<br>
<code>dark</code> ICT3.0图表深色主题<br>
<code>hdesign-light</code> H Design1.1图表浅色主题<br>
<code>hdesign-dark</code> H Design1.1图表深色主题<br>
<code>cloud-light</code> :华为云图表浅色主题<br>
<code>bpit-light</code> :质量&amp;流程IT图表浅色主题<br>
<code>bpit-dark</code> :质量&amp;流程IT图表深色主题</p>
</div></div></div></td></tr></div>`
},
{
name: 'Color',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:</p>
<p data-v-md-line="3">如<code>theme='light'</code>时color 取[ <span style="background:#6D8FF0;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #6D8FF0 <span style="background:#00A874;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #00A874 <span style="background:#BD72F0;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #BD72F0 <span style="background:#54BCCE;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #54BCCE <span style="background:#FDC000;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #FDC000 <span style="background:#9185F0;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #9185F0<span style="background:#00A2B5;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #00A2B5 ]<br>
如<code>theme='dark'</code>时color 取[ <span style="background:#1F55B5;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #1F55B5 <span style="background:#278661;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #278661 <span style="background:#8A21BC;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #8A21BC <span style="background:#26616B;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #26616B <span style="background:#B98C1D;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #B98C1D <span style="background:#745EF7;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #745EF7<span style="background:#2A8290;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #2A8290 ]<br>
如<code>theme='cloud-light'</code>时color 取[ <span style="background:#1476FF;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #1476FF <span style="background:#0BB8B2;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #0BB8B2 <span style="background:#6E51E0;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #6E51E0 <span style="background:#5CB300;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #5CB300 <span style="background:#FFB700;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #FFB700 <span style="background:#33BCF2;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #33BCF2 <span style="background:#BA53E6;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #BA53E6 <span style="background:#F24998;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #F24998 ]<br>
如<code>theme='cloud-dark'</code>时color 取[ color 取[ <span style="background:#1476FF;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #1476FF <span style="background:#0BB8B2;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #0BB8B2 <span style="background:#6E51E0;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #6E51E0 <span style="background:#5CB300;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #5CB300 <span style="background:#FFB700;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #FFB700 <span style="background:#33BCF2;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #33BCF2 <span style="background:#BA53E6;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #BA53E6 <span style="background:#F24998;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #F24998 ]<br>
如<code>theme='hdesign-light'</code>时color 取[ color 取[ <span style="background:#2070F3;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #2070F3 <span style="background:#87C859;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #87C859 <span style="background:#715AFB;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #715AFB <span style="background:#F69E39;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #F69E39 <span style="background:#2CB8C9;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #2CB8C9 <span style="background:#E049CE;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #E049CE <span style="background:#09AA71;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #09AA71 <span style="background:#FCD72E;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #FCD72E<span style="background:#B62BF7;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #B62BF7<span style="background:#ED448A;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #ED448A<span style="background:#0067D1;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #0067D1]<br>
如<code>theme='hdesign-dark'</code>时color 取[ color 取[ <span style="background:#2070F3;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #2070F3 <span style="background:#62B42E;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #62B42E <span style="background:#715AFB;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #715AFB <span style="background:#F4840C;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #F4840C <span style="background:#2CB8C9;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #2CB8C9 <span style="background:#D41DBC;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #D41DBC <span style="background:#09AA71;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #09AA71 <span style="background:#FCC800;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #FCC800<span style="background:#B62BF7;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #B62BF7<span style="background:#E61866;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #E61866<span style="background:#0067D1;display:inline-block;width:16px;height:16px;transform:translateY(3px)"></span> #0067D1]<br>
说明:调色盘颜色列表,图表从颜色数组中依次循环取得颜色使用,如果没有设置颜色列表 则会根据 <code>theme</code> 决定默认值。</p>
</div></div></div></td></tr></div>`
},
{
name: 'Tooltip',
type: 'interface',
code: `<div class="tiny-huicharts"><tr class="tiny-grid-body__expanded-row"><td class="tiny-grid-body__expanded-column" colspan="5"><div class="tiny-grid-body__expanded-cell"><div class="v-md-editor-preview main-editor api-table" style="tab-size: 2;"><div class="github-markdown-body"><p data-v-md-line="1">默认值:</p>
<div data-v-md-line="3"><div class="v-md-pre-wrapper v-md-pre-wrapper-d extra-class"><pre class="v-md-hljs-d"><code>tooltip 提示框组件tooltip.show = <span class="hljs-literal">true</span> 默认显示
</code></pre>
</div></div><p data-v-md-line="7">格式:</p>
<div data-v-md-line="9"><div class="v-md-pre-wrapper v-md-pre-wrapper-d extra-class"><pre class="v-md-hljs-d"><code>tooltip: {
show: <span class="hljs-literal">true</span>,
formatter: (params, ticket, callback) =&gt; {
let htmlString = <span class="hljs-string">'';
params.map((item, index) =&gt; {
if (index === 0) htmlString += item.name + '</span>&lt;br/&gt;<span class="hljs-string">';
htmlString +=
\` & lt; div& gt;
& lt; i style = "display:inline-block;width:10px;height:10px;background-color:\${item.color};" & gt;& lt; /i&gt;
& lt; span style = "margin-left:5px;color:#ffffff" & gt;
& lt; span style = "display:inline-block;width:100px;" & gt; \${ item.seriesName } User & lt; /span&gt;
& lt; span style = "font-weight:bold" & gt; \${ item.value } %& lt; /span&gt;
& lt; span style = "color:gray" & gt; out & lt; /span&gt;
& lt; span style = "color:red" & gt; \${ 100 - item.value } %& lt; /span&gt;
& lt; /span&gt;
& lt; /div&gt;\`;
});
return htmlString;
}
};
</span ></code ></pre >
</div ></div > <p data-v-md-line="32">说明:通过回调函数的参数,自行制作一个 HTML 片段<br>
详细参数解释见: <a target="_blank" href="https://echarts.apache.org/zh/option.html#tooltip.formatter">https://echarts.apache.org/zh/option.html#tooltip.formatter</a></p>
</div ></div ></div ></td></tr></div>`
}
]
}