-
Notifications
You must be signed in to change notification settings - Fork 141
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
refactor(ava/advisor): init new advisor pipeline & built-in modules to plugin-based architecture #784
Open
chenluli
wants to merge
6
commits into
refactor-advisor-pipeline
Choose a base branch
from
dev-refactor-pipeline1
base: refactor-advisor-pipeline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor(ava/advisor): init new advisor pipeline & built-in modules to plugin-based architecture #784
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a6af04d
refactor(ava/advisor): split visual-encoder and chart-type-recommend …
chenluli c35a204
refactor(ava/advisor): init new advisor pipeline & built-in modules t…
chenluli a86960e
fix(ava/advisor): fix single datapoint line chart and area chart
chenluli 3d32447
fix(ava/advisor): add advisor export types
chenluli 85cc0ce
feat(ava/advisor): add async and condition type to advisor plugin
chenluli 70b5899
refactor(ava/advisor): adjustments to the concepts and APIs of compon…
chenluli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
packages/ava/src/advisor/advise-pipeline/get-chart-Type.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './data-to-advices'; | ||
export * from './spec-generator'; | ||
export * from './data-processors'; | ||
export * from './plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './presets'; |
32 changes: 32 additions & 0 deletions
32
...ges/ava/src/advisor/advise-pipeline/plugin/presets/chart-type-recommend/get-chart-Type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { compareAdvices, scoreRules } from '../../../score-calculator'; | ||
|
||
import type { ChartKnowledge } from '../../../../../ckb'; | ||
import type { | ||
ScoringResultForChartType, | ||
BasicDataPropertyForAdvice, | ||
RuleModule, | ||
AdvisorOptions, | ||
AdvisorPipelineContext, | ||
} from '../../../../types'; | ||
|
||
export const getChartTypeRecommendations = ({ | ||
chartWiki, | ||
dataProps, | ||
ruleBase, | ||
options, | ||
advisorContext, | ||
}: { | ||
dataProps: BasicDataPropertyForAdvice[]; | ||
chartWiki: Record<string, ChartKnowledge>; | ||
ruleBase: Record<string, RuleModule>; | ||
options?: AdvisorOptions; | ||
advisorContext?: Pick<AdvisorPipelineContext, 'extra'>; | ||
}) => { | ||
const chatTypes = Object.keys(chartWiki); | ||
const list: ScoringResultForChartType[] = chatTypes.map((chartType) => { | ||
return scoreRules(chartType, chartWiki, dataProps, ruleBase, options, advisorContext); | ||
}); | ||
|
||
// filter and sorter | ||
return list.filter((advice) => advice.score > 0).sort(compareAdvices); | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/ava/src/advisor/advise-pipeline/plugin/presets/chart-type-recommend/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './get-chart-Type'; | ||
export { chartTypeRecommendPlugin } from './plugin-config'; |
24 changes: 24 additions & 0 deletions
24
...ages/ava/src/advisor/advise-pipeline/plugin/presets/chart-type-recommend/plugin-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { getChartTypeRecommendations } from './get-chart-Type'; | ||
|
||
import type { | ||
AdvisorPipelineContext, | ||
ChartTypeRecommendInput, | ||
ChartTypeRecommendOutput, | ||
AdvisorPluginType, | ||
} from '../../../../types'; | ||
|
||
export const chartTypeRecommendPlugin: AdvisorPluginType<ChartTypeRecommendInput, ChartTypeRecommendOutput> = { | ||
name: 'defaultChartTypeRecommend', | ||
execute(input: ChartTypeRecommendInput, context?: AdvisorPipelineContext): ChartTypeRecommendOutput { | ||
const { dataProps } = input; | ||
const { advisor, options, extra } = context || {}; | ||
const chartTypeRecommendations = getChartTypeRecommendations({ | ||
dataProps, | ||
chartWiki: advisor.ckb, | ||
ruleBase: advisor.ruleBase, | ||
options, | ||
advisorContext: { extra }, | ||
}); | ||
return { chartTypeRecommendations }; | ||
}, | ||
}; |
6 changes: 3 additions & 3 deletions
6
...ne/data-processors/get-data-properties.ts → ...ts/data-processors/get-data-properties.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...line/data-processors/get-selected-data.ts → ...sets/data-processors/get-selected-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
.../advise-pipeline/data-processors/index.ts → ...e/plugin/presets/data-processors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './get-data-properties'; | ||
export * from './get-selected-data'; | ||
export { dataProcessorPlugin } from './plugin-config'; |
26 changes: 26 additions & 0 deletions
26
packages/ava/src/advisor/advise-pipeline/plugin/presets/data-processors/plugin-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { cloneDeep } from 'lodash'; | ||
|
||
import { getDataProps } from './get-data-properties'; | ||
import { getSelectedData } from './get-selected-data'; | ||
|
||
import type { | ||
AdvisorPipelineContext, | ||
DataProcessorInput, | ||
DataProcessorOutput, | ||
AdvisorPluginType, | ||
} from '../../../../types'; | ||
|
||
export const dataProcessorPlugin: AdvisorPluginType<DataProcessorInput, DataProcessorOutput> = { | ||
name: 'defaultDataProcessor', | ||
execute: (input: DataProcessorInput, context: AdvisorPipelineContext): DataProcessorOutput => { | ||
const { data, customDataProps } = input; | ||
const { fields } = context?.options || {}; | ||
const copyData = cloneDeep(data); | ||
const dataProps = getDataProps(copyData, fields, customDataProps); | ||
const filteredData = getSelectedData({ data: copyData, fields }); | ||
return { | ||
data: filteredData, | ||
dataProps, | ||
}; | ||
}, | ||
}; |
4 changes: 4 additions & 0 deletions
4
packages/ava/src/advisor/advise-pipeline/plugin/presets/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './chart-type-recommend'; | ||
export * from './data-processors'; | ||
export * from './spec-generator'; | ||
export * from './visual-encoder'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ise-pipeline/spec-generator/charts/bar.ts → ...ugin/presets/spec-generator/charts/bar.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...-pipeline/spec-generator/charts/column.ts → ...n/presets/spec-generator/charts/column.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...pipeline/spec-generator/charts/heatmap.ts → .../presets/spec-generator/charts/heatmap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...peline/spec-generator/charts/histogram.ts → ...resets/spec-generator/charts/histogram.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ise-pipeline/spec-generator/charts/pie.ts → ...ugin/presets/spec-generator/charts/pie.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...pipeline/spec-generator/charts/scatter.ts → .../presets/spec-generator/charts/scatter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这里 size 处理是因为,在折线图数据只有单点数据时,由于默认 size 太小,一个点看不见,会误以为空白,需要手动加大 size
@hustcc 这个有其他方式么,或者要在 G2 处理吗,否则默认情况下这种离散点展示不太好,用户自己处理有点麻烦