-
Notifications
You must be signed in to change notification settings - Fork 605
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
feat: a new chart type - Box Chart #1382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests to make sure this change works as expected?
This pull request introduces 3 alerts when merging c4a613d into 4e2c047 - view on LGTM.com new alerts:
|
箱线图会做成什么样子,可以先简单描述吗? |
c4a613d
to
bbaec16
Compare
This pull request introduces 3 alerts when merging bbaec16 into a5f900c - view on LGTM.com new alerts:
|
export interface BoxOptions extends Options {
/** 分类字段 */
readonly catField: string;
/** 测量字段映射 box range [low, q1, median, q3, hight] 五个字段 */
readonly measureField: [string?, string?, string?, string?, string?];
/** 颜色字段 */
readonly colorField: string;
/** 柱子样式配置,可选 */
readonly boxStyle?: ShapeStyle | ((x: any, y: any, color?: any) => ShapeStyle);
/** 是否分组箱线图 默认 false*/
readonly isGroup?: boolean;
/** 分组拆分字段 默认 false*/
readonly groupField?: string;
/** outliers 字段 */
readonly outliersField: string;
/** 在直角坐标系还是极坐标系 默认 rect 直角坐标系*/
readonly coord: 'rect' | 'polar';
}
// 传入数据格式
interface BoxData {
x: string
low?: number
q1?: number
median?: number
q3?: number
high?: number
outliers?: number[] | number
} 处理边界:
|
height: 500, | ||
data: boxData, | ||
xField: 'x', | ||
yField: ['low', 'q1', 'median', 'q3', 'high'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是相当于 YField 一定要传 5 个参数,且严格按顺序(如果说缺少一个字段参数,会绘制不出来吗?比如说不需要展示中位线,是否可以不要第三个参数 median?又或者说 中间三个参数是否可以在内部用 data-set 计算就行了)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是相当于 YField 一定要传 5 个参数,且严格按顺序(如果说缺少一个字段参数,会绘制不出来吗?比如说不需要展示中位线,是否可以不要第三个参数 median?又或者说 中间三个参数是否可以在内部用 data-set 计算就行了)
- 需要按照顺序传5个参数
- 倒是不需要都传,不穿也可以绘制出来;
- median 不是由 q1 q3 或者 low high 决定的,而是由原数据决定的,http://tuzhidian.com/chart?id=5c666f91372bb033b9c2fa75
- 可以让用户只传原数据,我们ds处理,但是会不会数据量大,我看 g2 demo 是这样指定的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 个数据相当于是统计计算之后出来。如果按照直方图的套路,确实应该内置统计。
但是确实会增加数据量,而且数据理解成本可能更高了,我的想法是可以按照这样的方式,直接传五个字段。
|
This pull request introduces 1 alert when merging b091805 into eacf58f - view on LGTM.com new alerts:
|
examples/histogram/basic/API.en.md
Outdated
{ value: 56 }, | ||
{ value: 67 } | ||
]; | ||
const data = [{ value: 20 }, { value: 34 }, { value: 56 }, { value: 67 }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 diff 可以去掉。
This pull request introduces 1 alert when merging bb4b134 into eacf58f - view on LGTM.com new alerts:
|
| content | _boolean_, _object_ | 指标卡内容 | | ||
| formatter | _function_ | 通过回调的方式,设置指标卡内容 | | ||
| style | _object_ | 指标卡内容样式 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上。
| content | _boolean_, _object_ | 指标卡内容 | | ||
| formatter | _function_ | 通过回调的方式,设置指标卡内容 | | ||
| style | _object_ | 指标卡内容样式 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上。
This pull request introduces 1 alert when merging 465f938 into eacf58f - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 9c1e077 into eacf58f - view on LGTM.com new alerts:
|
src/plots/box/adaptor.ts
Outdated
import { BoxOptions } from './types'; | ||
import { flow, pick } from '../../utils'; | ||
import { AXIS_META_CONFIG_KEYS } from '../../constant'; | ||
import * as constant from './const'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { Range, xxx }
建议不使用 import * as yyy,因为这个就存在一个命名问题,不同人命名风格又不一样。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文件名就叫 constant.ts 吧,不用简写~
src/plots/box/adaptor.ts
Outdated
|
||
// make yField and outliersField share y mate | ||
if (outliersField) { | ||
const syncName = '$$y_outliers$$'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
常量,放到 constant.ts 中
src/plots/box/const.ts
Outdated
@@ -0,0 +1,2 @@ | |||
export const BOX_RANGE = '$$range$$'; | |||
export const BOX_RANGE_ALIAS = '区间信息'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 默认的名字用英文不?
src/plots/box/index.ts
Outdated
import { BoxOptions } from './types'; | ||
import { adaptor } from './adaptor'; | ||
import { deepMix } from '@antv/util'; | ||
import * as constant from './const'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { BOX_RANGE_ALIAS } from './constant';
src/plots/box/types.ts
Outdated
/** 分组拆分字段 */ | ||
readonly groupField?: string; | ||
/** 颜色字段,可选 */ | ||
readonly colorField?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new chart type: Box