-
Notifications
You must be signed in to change notification settings - Fork 450
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
Persist Topic Tree Data #1778
Merged
Merged
Persist Topic Tree Data #1778
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f8d9a88
refactor(desktop): update save message methods on topic tree
ysfscream 3dbbd17
test(desktop): update message queue buffer test cases
ysfscream 47295aa
test(desktop): update topic tree test case
ysfscream dc011ef
feat(desktop): persist tree data
ysfscream c0034f2
feat(desktop): update clear tree data text
ysfscream c2dc4e6
feat(desktop): support delete related message connections for topic tree
ysfscream 2b9f6e2
feat(desktop): update service methods
ysfscream be74ab3
feat(desktop): visualize topic tree support
ysfscream 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<template> | ||
<div :id="id" :style="{ width, height }"></div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Prop, Vue, Watch } from 'vue-property-decorator' | ||
import { Getter } from 'vuex-class' | ||
import * as echarts from 'echarts/core' | ||
import { TooltipComponent, LegendComponent } from 'echarts/components' | ||
import { TreeChart } from 'echarts/charts' | ||
import { CanvasRenderer } from 'echarts/renderers' | ||
|
||
echarts.use([TooltipComponent, LegendComponent, TreeChart, CanvasRenderer]) | ||
|
||
@Component | ||
export default class TreeChartComponent extends Vue { | ||
@Prop({ required: true }) public id!: string | ||
@Prop({ default: '400px' }) public height!: string | ||
@Prop({ default: '100%' }) public width!: string | ||
@Prop({ required: true }) public data!: TopicTreeNode[] | ||
@Prop({ default: 'vertical' }) public layout!: 'horizontal' | 'vertical' | ||
@Prop({ default: 7 }) public symbolSize!: number | ||
@Prop({ default: 'transparent' }) public backgroundColor!: string | ||
@Prop({ default: () => ({}) }) public tooltipFormatter!: (params: any) => string | Record<string, any> | ||
|
||
@Getter('currentTheme') private theme!: string | ||
|
||
private chart: echarts.ECharts | null = null | ||
|
||
@Watch('data', { deep: true }) | ||
@Watch('layout') | ||
@Watch('symbolSize') | ||
private onDataChanged() { | ||
this.updateChart() | ||
} | ||
|
||
private generateChartOption(): any { | ||
const treeData = this.data | ||
console.log(treeData) | ||
return { | ||
backgroundColor: this.backgroundColor, | ||
tooltip: { | ||
trigger: 'item', | ||
triggerOn: 'mousemove', | ||
formatter: this.tooltipFormatter, | ||
}, | ||
legend: { | ||
data: treeData.map((tree) => ({ | ||
name: tree.label, | ||
icon: 'rectangle', | ||
})), | ||
}, | ||
series: treeData.map((tree) => ({ | ||
type: 'tree', | ||
data: [tree], | ||
symbolSize: this.symbolSize, | ||
label: { | ||
position: 'left', | ||
verticalAlign: 'middle', | ||
align: 'right', | ||
}, | ||
leaves: { | ||
label: { | ||
position: 'right', | ||
verticalAlign: 'middle', | ||
align: 'left', | ||
}, | ||
}, | ||
emphasis: { | ||
focus: 'descendant', | ||
}, | ||
expandAndCollapse: true, | ||
animationDuration: 550, | ||
animationDurationUpdate: 750, | ||
})), | ||
} | ||
} | ||
|
||
private initChart() { | ||
const chartDom = document.getElementById(this.id) | ||
if (!chartDom) return | ||
|
||
this.chart = echarts.init(chartDom, this.theme !== 'light' ? 'dark' : 'light') | ||
this.updateChart() | ||
} | ||
|
||
private updateChart() { | ||
if (this.chart) { | ||
const option = this.generateChartOption() | ||
this.chart.setOption(option) | ||
} | ||
} | ||
|
||
mounted() { | ||
this.initChart() | ||
window.addEventListener('resize', this.handleResize) | ||
} | ||
|
||
beforeDestroy() { | ||
if (this.chart) { | ||
this.chart.dispose() | ||
} | ||
window.removeEventListener('resize', this.handleResize) | ||
} | ||
|
||
private handleResize = () => { | ||
if (this.chart) { | ||
this.chart.resize() | ||
} | ||
} | ||
} | ||
</script> |
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.
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.
This feature is currently a work in progress; please disregard it now and focus on the storage implementation. I need to synchronize the code, so I submitted the code that is in progress.