-
Notifications
You must be signed in to change notification settings - Fork 3
Add basic templates of visualisation charts utilized in EasyTexture #30
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
Changes from 7 commits
b0348e9
3e90431
73e7c86
37a45fe
b65e96f
fac7c98
d862631
e30b1d4
75ae0cd
53aa87e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import QtQuick | ||
| import QtQuick.Controls | ||
| import QtWebEngine | ||
|
|
||
| import EasyApp.Gui.Style as EaStyle | ||
| import Gui.Globals as Globals | ||
|
|
||
| WebEngineView { | ||
| id: chartView | ||
|
|
||
| property bool loadSucceededStatus: false | ||
| property string xAxisTitle: '' | ||
| property string yAxisTitle: '' | ||
|
|
||
| property var plotData: ({}) | ||
|
|
||
| width: parent.width | ||
| height: parent.height | ||
|
|
||
| url: Qt.resolvedUrl('../Html/Plotly1dBarPlot.html') | ||
|
|
||
| onLoadSucceededStatusChanged: { | ||
| if (loadSucceededStatus) { | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onLoadingChanged: { | ||
| // Bug 'loadRequest' is not declared - https://bugreports.qt.io/browse/QTBUG-84746 | ||
| //if (loadRequest.status === WebEngineView.LoadSucceededStatus) { | ||
| if (loadProgress === 100) { | ||
| loadSucceededStatus = true | ||
| } | ||
| } | ||
|
|
||
| onXAxisTitleChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXAxisTitle() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onYAxisTitleChanged: { | ||
| if (loadSucceededStatus) { | ||
| setYAxisTitle() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onPlotDataChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXyData() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| // Logic | ||
|
|
||
| function redrawPlot() { | ||
| chartView.runJavaScript(`redrawPlot()`) | ||
| } | ||
|
|
||
| function setXAxisTitle() { | ||
| runJavaScript(`setXAxisTitle(${JSON.stringify(xAxisTitle)})`) | ||
| } | ||
|
|
||
| function setYAxisTitle() { | ||
| runJavaScript(`setYAxisTitle(${JSON.stringify(yAxisTitle)})`) | ||
| } | ||
|
|
||
| function setXyData() { | ||
| runJavaScript(`setXyData(${JSON.stringify(plotData)})`) | ||
| } | ||
|
|
||
| function redrawPlotWithAnimation() { | ||
| runJavaScript(`redrawPlotWithAnimation(${JSON.stringify(plotData)})`) | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,16 +8,18 @@ WebEngineView { | |
| property bool loadSucceededStatus: false | ||
| property string xAxisTitle: '' | ||
| property string yAxisTitle: '' | ||
| property string colorbarTitle: '' | ||
|
Member
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.
Author
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. thanks, I added |
||
|
|
||
| property var plotData: ({}) | ||
| property var shapes: ([{}]) | ||
|
|
||
| width: parent.width | ||
| height: parent.height | ||
|
|
||
| url: Qt.resolvedUrl('../Html/Plotly2dHeatmap.html') | ||
| url: Qt.resolvedUrl('../Html/Plotly2dHeatmap.html') | ||
|
|
||
| onLoadSucceededStatusChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXAxisTitle(xAxisTitle) | ||
| setYAxisTitle(yAxisTitle) | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
@@ -32,14 +34,28 @@ WebEngineView { | |
|
|
||
| onXAxisTitleChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXAxisTitle(newTitle) | ||
| setXAxisTitle() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onYAxisTitleChanged: { | ||
| if (loadSucceededStatus) { | ||
| setYAxisTitle(newTitle) | ||
| setYAxisTitle() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onPlotDataChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXyzData() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onShapesChanged: { | ||
| if (loadSucceededStatus) { | ||
| setShape() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
@@ -50,12 +66,24 @@ WebEngineView { | |
| chartView.runJavaScript(`redrawPlot()`) | ||
| } | ||
|
|
||
| function setXAxisTitle(newTitle) { | ||
| runJavaScript(`setXAxisTitle(${JSON.stringify(newTitle)})`) | ||
| function setXAxisTitle() { | ||
| runJavaScript(`setXAxisTitle(${JSON.stringify(xAxisTitle)})`) | ||
| } | ||
|
|
||
| function setYAxisTitle() { | ||
| runJavaScript(`setYAxisTitle(${JSON.stringify(yAxisTitle)})`) | ||
| } | ||
|
|
||
| function setShape() { | ||
| runJavaScript(`setShape(${JSON.stringify(shapes)})`) | ||
| } | ||
|
|
||
| function setColorbarTitle() { | ||
| runJavaScript(`setColorbarTitle(${JSON.stringify(colorbarTitle)})`) | ||
| } | ||
|
|
||
| function setYAxisTitle(newTitle) { | ||
| runJavaScript(`setYAxisTitle(${JSON.stringify(newTitle)})`) | ||
| function setXyzData() { | ||
| runJavaScript(`setXyzData(${JSON.stringify(plotData)})`) | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import QtQuick | ||
| import QtQuick.Controls | ||
| import QtWebEngine | ||
|
|
||
| import Gui.Globals as Globals | ||
|
|
||
| WebEngineView { | ||
| id: chartView | ||
|
|
||
| property bool loadSucceededStatus: false | ||
| property string colorbarTitle: '' | ||
|
|
||
| property var plotData: ({}) | ||
|
|
||
| width: parent.width | ||
| height: parent.height | ||
|
|
||
| url: Qt.resolvedUrl('../Html/Plotly2dPolarHeatmap.html') | ||
|
|
||
| onLoadSucceededStatusChanged: { | ||
| if (loadSucceededStatus) { | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onLoadingChanged: { | ||
| // Bug "loadRequest" is not declared - https://bugreports.qt.io/browse/QTBUG-84746 | ||
| //if (loadRequest.status === WebEngineView.LoadSucceededStatus) { | ||
| if (loadProgress === 100) { | ||
| loadSucceededStatus = true | ||
| } | ||
| } | ||
|
|
||
| onColorbarTitleChanged: { | ||
| if (loadSucceededStatus) { | ||
| setColorbarTitle() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| onPlotDataChanged: { | ||
| if (loadSucceededStatus) { | ||
| setXyzData() | ||
| redrawPlot() | ||
| } | ||
| } | ||
|
|
||
| // Logic | ||
|
|
||
| function redrawPlot() { | ||
| chartView.runJavaScript(`redrawPlot()`) | ||
| } | ||
|
|
||
| function setColorbarTitle() { | ||
| runJavaScript(`setColorbarTitle(${JSON.stringify(colorbarTitle)})`) | ||
| } | ||
|
|
||
| function setXyzData() { | ||
| runJavaScript(`setXyzData(${JSON.stringify(plotData)})`) | ||
| } | ||
|
|
||
| } |
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.
If
setXAxisTitle(),setYAxisTitle(), andsetXyData()(nowsetPlotData()) are not called after the HTML page finishes loading, then the chart keeps using the default values hardcoded in the HTML template, not the values already set in the QML wrapper.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.
good points, thanks. I added these lines here and in the other charts as well