ECharts Configuration
Used to configure the default display behavior of the popup when inserting charts. If you want to customize the ECharts chart configuration. Added in v6.0.0
Default Configuration
{
echarts: {
mode: 1,
haveImage: false,
onCustomSettings() {
return null
},
},
}
Configuration Options
echarts.mode
Description: The default mode opened when setting up the chart.
Type: Number
Default Value: 1
Options:
0
: Directly use the options JSON source mode of ECharts.1
: Visualization mode, allowing you to create charts through configuration.
echarts.renderImage
Description: Whether to render as an image. If true
, an ECharts image will be saved while displaying the image. This is mainly used in scenarios where complex graphics cannot be generated by Word but require a similar effect.
Type: Boolean
Default Value: false
Options:
true
: Generate an image.false
: Do not generate an image.
echarts.onCustomSettings
Description: Custom ECharts options method.
Type: Function
.
Parameters:
data
:Array
, ECharts chart data.config
:Object
, current ECharts chart configuration.seriesType
:String
, chart display typebar|line|pie
representing bar chart, line chart, and pie chart respectivelylegend
:Boolean
, whether to show legendtrue
: show legend,false
: hide legendlegendleft
:String
, legend horizontal positionleft|center|right
representing left, center, and right alignment respectivelylegendlocation
:String
, legend vertical positiontop|bottom
representing top and bottom alignment respectivelylegendorient
:String
, legend layout orientationhorizontal|vertical
representing horizontal and vertical layout respectivelysmooth
:Boolean
, whether to smooth line chart displaytrue
: smooth display,false
: default displaytitleText
:String
, chart title contenttitleleft
:String
, chart title positionleft|center|right
representing left, center, and right alignment respectively
Example:
The following code demonstrates how to configure the onCustomEChartSettings method to implement chart customization:
import { useUmoEditor } from '@umoteam/editor'
const options = {
echarts: {
onCustomSettings(data, config) {
const { title, seriesType, legend } = config
const option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line',
smooth: true,
},
],
}
return option
},
},
}
app.use(useUmoEditor, options)
Return Value:Object
,return ECharts options configuration object.