设置个性配置

来自源数据源

function getOptions(page: DesignerPageBase, cmp: EcLineChart) {
    return {
        "title": {
            "show": true, "text": "图表示例",
            "left": "left"
        },
        "noDataLoadingOption": {
            "text": "暂无数据",
            "effect": "whirling",
            "effectOption": { "backgroundColor": "rgba(50,50,50,0)" },
            "textStyle": { "fontSize": 32, "fontWeight": "bold" }
        },
        "tooltip": {
            "show": true, "trigger": "axis",
            "axisPointer": {
                "type": "cross",
                "label": { "backgroundColor": "#6a7985" }
            }
        },
        "toolbox": {
            "show": true, "orient": "horizontal",
            "feature": {
                "dataZoom": { "yAxisIndex": "none" },
                "dataView": { "readOnly": false },
                "magicType": {
                    "type": ["line",
                        "bar"]
                },
                "restore": {},
                "saveAsImage": {}
            }
        },
        "legend": {},
        xAxis: {
            type: 'category',
            data: cmp.getPage().components.SqlDataSetBase1.getDataArrayByField('X')
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: cmp.getPage().components.SqlDataSetBase1.getDataArrayByField('Y'),
                type: 'line'
            }
        ]
    }
}

来自ajax

function getOptions(page: DesignerPageBase, cmp: EcLineChart) {
    let  datas;
    //通过ajax获取图表的数据
    Common.asyncAjax("xxxx/yyyyy",'post', null,function(res){
        if(res.state=='ok'){
            datas=res.obj;
        }
    })
    return {
        "title": {
            "show": true, "text": "图表示例",
            "left": "left"
        },
        "noDataLoadingOption": {
            "text": "暂无数据",
            "effect": "whirling",
            "effectOption": { "backgroundColor": "rgba(50,50,50,0)" },
            "textStyle": { "fontSize": 32, "fontWeight": "bold" }
        },
        "tooltip": {
            "show": true, "trigger": "axis",
            "axisPointer": {
                "type": "cross",
                "label": { "backgroundColor": "#6a7985" }
            }
        },
        "toolbox": {
            "show": true, "orient": "horizontal",
            "feature": {
                "dataZoom": { "yAxisIndex": "none" },
                "dataView": { "readOnly": false },
                "magicType": {
                    "type": ["line",
                        "bar"]
                },
                "restore": {},
                "saveAsImage": {}
            }
        },
        "legend": {},
        xAxis: {
            type: 'category',
            data: datas['X']
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data:  data: datas['Y'],
                type: 'line'
            }
        ]
    }
}
作者:admin  创建时间:2023-01-12 10:24
最后编辑:admin  更新时间:2024-04-26 09:11