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

G2 Spec 的序列化,便于 SSR 的时候纯 JSON #6542

Open
1 task done
hustcc opened this issue Dec 6, 2024 · 1 comment
Open
1 task done

G2 Spec 的序列化,便于 SSR 的时候纯 JSON #6542

hustcc opened this issue Dec 6, 2024 · 1 comment

Comments

@hustcc
Copy link
Member

hustcc commented Dec 6, 2024

AntV Open Source Contribution Plan(可选)

  • 我同意将这个 Issue 参与 OSCP 计划

Issue 类型

中级任务

任务介绍

我们在做 G2 SSR 的时候,会只用一个 json 配置描述图表,然后这个 json 会由用户输入并存储到数据库中。

但是 G2 Spec 有一些配置时使用回调函数实现,没有办法序列,所以需要有一个方案:用一个规范的字符串去描述简单函数。

{
  encode: {
    x: (d) => d.type
  }
}

改成使用(仅做示意,不干扰方案设计):

{
  "encode": {
    "x": "{d.type}"
  }
}

原则:

  1. 仅仅支持简单的函数回调,不用完全覆盖所有的函数逻辑
  2. 安全性

参考说明

可以参考 echarts、highcharts 等如何处理。

@BQXBQX
Copy link
Contributor

BQXBQX commented Dec 6, 2024

认领

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

No branches or pull requests

2 participants