跳到主要内容

示例

条形图

PCPhonePad

<page >
<module height="400px" style="margin: 0">
<customchart :options="options" :beforeRender="beforeRender9">
</customchart>
</module>
</page>

export default XPage({
data: {
options: {
'tooltip': {
axisPointer: {
type: 'shadow'
}
},
'legend': {'data': ['邮件营销', '联盟广告', '视频广告']},
'xAxis': {
'type': 'value',
name: '总量',
axisLabel: {
show: true,
formatter: '{value}%'
}
},
'yAxis': {
type: 'category',
'data': ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07']

},
'series': [
{
name: '邮件营销',
type: 'bar',
stack: '总量',
'barMaxWidth': 30,
data: [37.39, 33.33, 44.29, 39.27, 54.01, 22, 78.33]
}
]
}
},
beforeRender9 (opt/*系统默认配置*/, options/*用户传入的options*/, colors/*默认颜色配置*/) {
/*条形图在柱状图基础上调换xAxis 和yAxis配置即可*/
return options
}
});


PCPhonePad

<page >
<module height="400px" style="margin: 0">
<customchart :options="options" :beforeRender="beforeRender10">
</customchart>
</module>
</page>

export default XPage({
data: {
options: {
/*bar 需要配置tooltip类型*/
'tooltip': {
axisPointer: {
type: 'shadow'
}
},
'legend': {'data': ['Forest', 'Steppe', 'Desert', 'Wetland']},
'xAxis': {
'type': 'value',
'name': '总量'
},
'yAxis': {
type: 'category',
'data': ['01/01', '01/02', '01/03', '01/04', '01/05']

},
'series': [
{
name: 'Forest',
type: 'bar',
'barMaxWidth': 30,
data: [320, 332, 301, 334, 390]
},
{
name: 'Steppe',
type: 'bar',
'barMaxWidth': 30,
data: [220, 182, 191, 234, 290]
},
{
name: 'Desert',
type: 'bar',
'barMaxWidth': 30,
data: [150, 232, 201, 154, 190]
},
{
name: 'Wetland',
type: 'bar',
'barMaxWidth': 30,
data: [98, 77, 101, 99, 40]
}
]
}
},
beforeRender10 (opt/*系统默认配置*/, options/*用户传入的options*/, colors/*默认颜色配置*/) {
/*条形图在柱状图基础上调换xAxis 和yAxis配置即可*/
return options
}
});



PCPhonePad

<page >
<module height="400px" style="margin: 0">
<customchart :options="options" :beforeRender="beforeRender11">
</customchart>
</module>
</page>

export default XPage({
data: {
options: {
'tooltip': {
axisPointer: {
type: 'shadow'
}
},
'legend': {'data': ['邮件营销', '联盟广告', '视频广告']},
'xAxis': {
'type': 'value',
name: '总量',
axisLabel: {
show: true,
formatter: '{value}%'
}
},
'yAxis': {
type: 'category',
'data': ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07']

},
'series': [
{
name: '邮件营销',
type: 'bar',
stack: '总量',
data: [37.39, 33.33, 44.29, 39.27, 54.01, 22, 78.33]
},
{
name: '联盟广告',
type: 'bar',
stack: '总量',

data: [30.43, 29.41, 52.86, 69.86, 72.09, 22, 10]
},
{
name: '视频广告',
type: 'bar',
stack: '总量',
data: [26.09, 42.86, 60.94, 71.63, 69.41, 22, 12]
}
]
}
},
beforeRender11 (opt/*系统默认配置*/, options/*用户传入的options*/, colors/*默认颜色配置*/) {
/*条形图在柱状图基础上调换xAxis 和yAxis配置即可*/
return options
}
});


PCPhonePad

<page >
<module height="400px" style="margin: 0">
<customchart :options="options" :beforeRender="beforeRender13">
</customchart>
</module>
</page>

export default XPage({
data: {
options: {
'tooltip': {
axisPointer: {
type: 'shadow'
}
},
'legend': {'data': ['邮件营销', '联盟广告', '视频广告']},
'xAxis': {
'type': 'value',
name: '总量',
axisLabel: {
show: true,
formatter: '{value}%'
}
},
'yAxis': {
type: 'category',
'data': ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07']

},
'series': [
{
name: '邮件营销',
type: 'bar',
stack: '总量',
data: [37.39, 33.33, 44.29, 39.27, 54.01, 22, 78.33]
},
{
name: '联盟广告',
type: 'bar',
stack: '总量',

data: [30.43, 29.41, 52.86, 69.86, 72.09, 22, 10]
},
{
name: '视频广告',
type: 'bar',
stack: '总量',
data: [26.09, 42.86, 60.94, 71.63, 69.41, 22, 12]
}
]
}
},
beforeRender13 (opt/*系统默认配置*/, options/*用户传入的options*/, colors/*默认颜色配置*/) {
/*条形图在柱状图基础上调换xAxis 和yAxis配置即可*/
return options;
}
});


PCPhonePad

<page style='padding: 10px'>
<module height='400px' style='margin: 0'>
<customchart :options='options' :beforeRender='beforeRender14'>
</customchart>
</module>
</page>

export default XPage({
data:{options:{
'legend': { 'data': ['线下', '线上', '线上占比'] },
'xAxis': {
'data': ['01/01', '01/02', '01/03', '01/04', '01/05', '01/06', '01/07']
},
'yAxis': [
{
type: 'value',
'scale': true
},
{
type: 'value',
'scale': true,
'splitLine': { 'show': false }
}
],
'series': [
{
'type': 'bar',
'name': '线上',
'stack': 'Y',
'yAxisIndex': null,
'data': ['382679', '356571', '344679', '291502', '312182', '284532']
},
{
'type': 'bar',
'name': '线下',
'stack': 'Y',
'yAxisIndex': null,
'data': ['354293', '325546', '307062', '237523', '256711', '176690']
},
{
'type': 'line',
'name': '线上占比',
'stack': null,
'yAxisIndex': '1',
'data': ['51.93', '52.27', '52.89', '55.10', '54.88', '61.69']
}]
}},
beforeRender14(opt/*系统默认配置*/, options/*用户传入的options*/, colors/*默认颜色配置*/) {
/*注意yAxis配置*/
return options
},
});


Attribute

参数说明类型可选值默认值版本
options图表配置,符合echart配置项stringPC/Mobile--

event

参数说明类型版本
beforeRender每次渲染前处理options,参数(opt,options,color,callback,lighting高亮色),需要返回真实optionsfunctionPC/Mobile--
chartchart实例,用于自定义chart事件处理chartInstancePC/Mobile--

beforeRender

参数说明类型版本
opt系统默认配置包含tooltip\ xAxis\ yAxis\grid\legendStringPC/Mobile--
options用户配置项functionPC/Mobile--
colors当前渲染颜色 (使用默认即可)ArrayPC/Mobile--
lighting高亮颜色 (使用默认即可)ArrayPC/Mobile--