Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥰 [FEATURE] 回归散点图增加显示拟合函数的配置项 #3474

Closed
Cuiyansong opened this issue Feb 21, 2023 · 7 comments · Fixed by #3476
Closed

🥰 [FEATURE] 回归散点图增加显示拟合函数的配置项 #3474

Cuiyansong opened this issue Feb 21, 2023 · 7 comments · Fixed by #3476

Comments

@Cuiyansong
Copy link
Contributor

Cuiyansong commented Feb 21, 2023

🥰 Features description [Please make everyone to understand it]

希望如ECharts回归散点图一样,允许展示回归后的函数方程式(例如下图红框中的内容),进而判断回归参考线是否有意义。

🏞 What problem does this feature solve

🧐 What does the proposed API look like

最终可能实现的样式基本可以参考G2的示例,唯一需要开发的从regression函数(如d3-regression中的out值)中获取不同回归函数的方程式替代G2示例中的label.text中的内容,这样是否合理?

🚑 Any additional [like screenshots]

ECharts示例参考:
WX20230221-nihe

@hustcc
Copy link
Member

hustcc commented Feb 21, 2023

@Cuiyansong 在 G2 中这么做还是挺合理的,到 G2Plot 中,也有相关的 demo。你不确定是否合理的是指什么?

@Cuiyansong
Copy link
Contributor Author

Cuiyansong commented Feb 21, 2023

我期望的需求是在图形上显示出回归函数的方程式,回归方程式是从运算的函数中获取的,而不是在“外部自定义”或者如G2的示例中的“写死的/固定的”一个方程式。

不确定是否合理的是:在G2Plot中扩展RegressionLine配置参数,例如增加项{ showEquation: boolean }, 如果为true的话,则显示的效果类似上面的EChart的现实方式(红框内的方程式)

注释:

  • “外部自定义”的方式指的是使用G2Plot的RegressionLine配置参数中的algorithm+d3-regression计算并获取,这种方式的弊端是要在用户端重新引入d3-regression依赖,而且还需要将自定义内容使用G2Plot渲染出来。

@Cuiyansong
Copy link
Contributor Author

Cuiyansong commented Feb 21, 2023

再次确认下,目前在G2Plot中无法显示上图中红框内的方程式吧?

@Cuiyansong Cuiyansong changed the title 🥰 [FEATURE] 回归散点图增加显示拟合函数配置 🥰 [FEATURE] 回归散点图增加显示拟合函数的配置项 Feb 21, 2023
@Cuiyansong
Copy link
Contributor Author

Cuiyansong commented Feb 21, 2023

参考了源码的adaptor.ts中的regressionLine函数,大体改造思路如下:

step1: 开启显示

regressionLine: {
    showEquation: true
}

step2: 改造util.ts中的getPath方法,增加equation值返回
image

step3: 使用annotation显示方程式文本值
image

@hustcc
Copy link
Member

hustcc commented Feb 21, 2023

@Cuiyansong 👍🏻 你的思路是对的,应该是需要内置一个文本,显示公式的,以及公式文本的样式。有兴趣来 PR 吗?

@Cuiyansong
Copy link
Contributor Author

可以试试

@Cuiyansong
Copy link
Contributor Author

@hustcc 您好,已经提交了一个PR,方便的时候帮忙Review一下,不足的地方在补齐。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants