-
Notifications
You must be signed in to change notification settings - Fork 632
Embedding visualization connect #356
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
Merged
jetfuel
merged 8 commits into
PaddlePaddle:develop
from
jetfuel:embedding_visualization_connect
Apr 3, 2018
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
08de1fa
Make the frontend to fetch the data from the flask server.
jetfuel 29b2624
Provide loading animation.
jetfuel 48b9121
Merge branch 'develop' into embedding_visualization_connect
jetfuel 8e2ed68
Fixed format style
jetfuel e7fbf47
Provide a 2D 3D switcher.
jetfuel 2e1d56f
Include PCA method to do dimension reduction
jetfuel cd5ffd6
Fix the style.
jetfuel 1f7469e
Fix typo
jetfuel 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,9 +7,10 @@ | |
|
|
||
| <script> | ||
| import echarts from 'echarts'; | ||
| import 'echarts-gl'; | ||
|
|
||
| export default { | ||
| props: ['config', 'displayWordLabel', 'searchText', 'embedding_data'], | ||
| props: ['config', 'displayWordLabel', 'searchText', 'embedding_data', 'dimension'], | ||
| data() { | ||
| return { | ||
| width: 900, | ||
|
|
@@ -18,20 +19,21 @@ export default { | |
| }, | ||
| computed: { | ||
| computedStyle() { | ||
| return 'height:' + this.height + 'px;' | ||
| + 'width:' + this.width + 'px;'; | ||
| return 'height:' + this.height + 'px;' + | ||
| 'width:' + this.width + 'px;'; | ||
| } | ||
| }, | ||
| created() { | ||
|
|
||
| }, | ||
| created() {}, | ||
| mounted() { | ||
| this.createChart(); | ||
| this.setChartsOptions(); | ||
| this.myChart.showLoading() | ||
|
|
||
| this.set2DChartOptions(); | ||
| this.setDisplayWordLabel(); | ||
| }, | ||
| watch: { | ||
| embedding_data: function(val) { | ||
| this.myChart.hideLoading(); | ||
| this.myChart.setOption({ | ||
| series: [{ | ||
| // Grab the 'matched' series data | ||
|
|
@@ -43,13 +45,25 @@ export default { | |
| displayWordLabel: function(val) { | ||
| this.setDisplayWordLabel() | ||
| }, | ||
| dimension: function(val) { | ||
| this.myChart.clear() | ||
| this.myChart.showLoading() | ||
| if (val == "2") { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should use a "===" |
||
| this.set2DChartOptions(); | ||
| this.setDisplayWordLabel(); | ||
| } else { | ||
| this.set3DChartOptions(); | ||
| this.setDisplayWordLabel(); | ||
| } | ||
| }, | ||
| searchText: function(val) { | ||
| // Filter the data that has the hasPrefix | ||
| var matched_words = [] | ||
| if (val != '') { | ||
| val = val.toLowerCase() | ||
|
|
||
| function hasPrefix(value) { | ||
| var word = value[2] | ||
| var word = value[value.length - 1] | ||
| return (typeof word == "string" && word.toLowerCase().startsWith(val)) | ||
| } | ||
|
|
||
|
|
@@ -72,13 +86,12 @@ export default { | |
| let el = this.$refs.chartBox; | ||
| this.myChart = echarts.init(el); | ||
| }, | ||
| setChartsOptions(){ | ||
| set2DChartOptions() { | ||
| var typeD = "normal"; | ||
| var option = { | ||
| xAxis: {}, | ||
| yAxis: {}, | ||
| series: [ | ||
| { | ||
| series: [{ | ||
| name: "all", | ||
| symbolSize: 10, | ||
| data: this.embedding_data, | ||
|
|
@@ -87,45 +100,87 @@ export default { | |
| { | ||
| name: "matched", | ||
| animation: false, | ||
| symbolSize:10, | ||
| symbolSize: 10, | ||
| data: [], | ||
| itemStyle: { | ||
| normal: { | ||
| opacity: 1 | ||
| } | ||
| }, | ||
| label: { | ||
| normal: { | ||
| show: true, | ||
| formatter: function(param) { | ||
| return param.data[param.data.length - 1]; | ||
| }, | ||
| position: 'top' | ||
| } | ||
| }, | ||
| type: 'scatter' | ||
| } | ||
| ] | ||
| }; | ||
| this.myChart.setOption(option); | ||
| }, | ||
| set3DChartOptions() { | ||
| var symbolSize = 2.5; | ||
| var option3d = { | ||
| grid3D: {}, | ||
| xAxis3D: { | ||
| type: 'category' | ||
| }, | ||
| yAxis3D: {}, | ||
| zAxis3D: {}, | ||
| dataset: { | ||
| source: this.embedding_data | ||
| }, | ||
| series: [ | ||
| { | ||
| name: "all", | ||
| type: 'scatter3D', | ||
| symbolSize: symbolSize, | ||
| data: [] | ||
| }, | ||
| { | ||
| name: "matched", | ||
| animation: false, | ||
| symbolSize: symbolSize, | ||
| data: [], | ||
| label: { | ||
| normal: { | ||
| show: true, | ||
| formatter: function (param) { | ||
| return param.data[2]; | ||
| formatter: function(param) { | ||
| return param.data[param.data.length - 1]; | ||
| }, | ||
| position: 'top' | ||
| } | ||
| }, | ||
| type: 'scatter' | ||
| } | ||
| ] | ||
| }; | ||
| this.myChart.setOption(option); | ||
| type: 'scatter3D' | ||
| } | ||
| ] | ||
| } | ||
| this.myChart.setOption(option3d); | ||
| }, | ||
| setDisplayWordLabel() { | ||
| this.myChart.setOption({ | ||
| this.myChart.setOption({ | ||
| series: [{ | ||
| // Grab the 'all' series data | ||
| name: 'all', | ||
| label: { | ||
| normal: { | ||
| show: this.displayWordLabel, | ||
| formatter: function (param) { | ||
| return param.data[2]; | ||
| }, | ||
| position: 'top' | ||
| formatter: function(param) { | ||
| return param.data[param.data.length - 1]; | ||
| }, | ||
| emphasis: { | ||
| show: true, | ||
| } | ||
| position: 'top' | ||
| }, | ||
| emphasis: { | ||
| show: true, | ||
| } | ||
| }) | ||
| } | ||
| }] | ||
| }); | ||
| }, | ||
|
|
||
| } | ||
| }; | ||
|
|
||
|
|
@@ -136,7 +191,4 @@ export default { | |
| float left | ||
| padding 10px | ||
| position relative | ||
|
|
||
|
|
||
|
|
||
| </style> | ||
This file contains hidden or 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.
dimension