Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

希望可以修改下render方法,以能支持回调函数的写法 #79

Open
@leacoleaco

Description

@leacoleaco

希望可以修改下render方法,以能支持配置中使用回调函数的写法?

比如:
饼图的Series 里有一个 labelLayout 配置, 这个配置可以写成函数回调的方式:
echarts 支持这么设置:

{series:[{labelLayout:function(params){constisLeft=params.labelRect.x<myChart.getWidth()/2;constpoints=params.labelLinePoints;// Update the end point.points[2][0]=isLeft          ?params.labelRect.x          :params.labelRect.x+params.labelRect.width;return{labelLinePoints:points};}}]}

但是PieSeries 只有这样的配置方法

PieSeries().setLabelLayout(LabelLayout())

这样怎么配置都没法做到回调里的那种显示方案。

所以我在想是不是可以弄一个支持回调的类, render 时候可以把这部分渲染为回调函数,以解决这个问题? 比如可以这么配置:

PieSeries()   .setLabelLayout(CallbackScript("function (params) {" +"   const isLeft = params.labelRect.x < myChart.getWidth() / 2;" +"   const points = params.labelLinePoints;" +"   // Update the end point." +"   points[2][0] = isLeft" +"     ? params.labelRect.x" +"    : params.labelRect.x + params.labelRect.width;" +"  return {" +"    labelLinePoints: points" +"  };" +" }" +"}"))

就能在render时得到上面的那个配置

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp