Skip to content

Commit 2de487e

Browse files
committed
Merge branch 'master' into develop
2 parents 8986fae + 2fe0df4 commit 2de487e

4 files changed

+330
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
5+
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
6+
7+
<style type="text/css">
8+
9+
* {
10+
margin: 0;
11+
padding: 0;
12+
box-sizing: border-box;
13+
}
14+
15+
body {
16+
overflow: hidden;
17+
font-family: "PT Sans", sans-serif;
18+
}
19+
20+
#chartDiv {
21+
width: 100vw;
22+
height: 100vh;
23+
}
24+
25+
</style>
26+
27+
<body>
28+
29+
<div id="chartDiv"></div>
30+
31+
<script>
32+
33+
let z3dValues = []
34+
35+
function setZ3dValues(newValues) {
36+
z3dValues = newValues
37+
}
38+
39+
function redrawPlot() {
40+
data = [{
41+
z: z3dValues,
42+
type: 'heatmap'
43+
}]
44+
Plotly.newPlot('chartDiv', data)
45+
}
46+
47+
</script>
48+
49+
</body>
50+
51+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
5+
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
6+
7+
<style type="text/css">
8+
9+
:root {
10+
--xAxisTitle:"";
11+
--yAxisTitle:"";
12+
}
13+
14+
* {
15+
margin: 0;
16+
padding: 0;
17+
box-sizing: border-box;
18+
}
19+
20+
body {
21+
overflow: hidden;
22+
font-family: "PT Sans", sans-serif;
23+
}
24+
25+
#chartDiv {
26+
width: 100vw;
27+
height: 100vh;
28+
}
29+
30+
</style>
31+
32+
<body>
33+
34+
<div id="chartDiv"></div>
35+
36+
<script>
37+
38+
/* GLOBAL VARIABLES */
39+
40+
let xArrayValues = []
41+
let yArrayValues = []
42+
43+
/* PLOT DESCRIPTION */
44+
45+
let data = [{
46+
x: xArrayValues,
47+
y: yArrayValues,
48+
mode: 'lines',
49+
//line: {simplify: false},
50+
//type: 'scattergl',
51+
}]
52+
53+
let layout = {
54+
autosize: true,
55+
xaxis: {
56+
title: '',
57+
automargin: true,
58+
autorange: true,
59+
showgrid: true,
60+
zeroline: false,
61+
showline: true,
62+
mirror: 'ticks',
63+
},
64+
yaxis: {
65+
title: '',
66+
automargin: true,
67+
showgrid: true,
68+
zeroline: false,
69+
showline: true,
70+
mirror: 'ticks',
71+
},
72+
margin: {
73+
l: 43,
74+
r: 3,
75+
b: 50,
76+
t: 40,
77+
pad: 0
78+
}
79+
}
80+
81+
let config = {
82+
displayModeBar: true,
83+
displaylogo: false,
84+
}
85+
86+
/* CREATE PLOT */
87+
88+
Plotly.newPlot('chartDiv', data, layout, config)
89+
90+
/* FUNCTIONS */
91+
92+
function setXArrayValues(newValues) {
93+
xArrayValues.length = 0
94+
for (let i = 0; i < newValues.length; i++) {
95+
xArrayValues[i] = newValues[i]
96+
}
97+
}
98+
99+
function setYArrayValues(newValues) {
100+
yArrayValues.length = 0
101+
for (let i = 0; i < newValues.length; i++) {
102+
yArrayValues[i] = newValues[i]
103+
}
104+
}
105+
106+
function redrawPlot() {
107+
Plotly.redraw('chartDiv')
108+
}
109+
110+
function redrawPlotWithYAnimation() {
111+
Plotly.animate('chartDiv', {
112+
data: [{ y: yArrayValues }],
113+
traces: [0]
114+
}, {
115+
transition: {
116+
duration: 500,
117+
easing: 'cubic-in-out'
118+
},
119+
frame: {
120+
duration: 500
121+
}
122+
})
123+
}
124+
125+
function setXAxisTitle(newTitle) {
126+
layout.xaxis.title.text = newTitle
127+
}
128+
129+
function setYAxisTitle(newTitle) {
130+
layout.yaxis.title.text = newTitle
131+
}
132+
133+
</script>
134+
135+
</body>
136+
137+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// SPDX-FileCopyrightText: 2022 EasyTexture contributors
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
// © 2022 Contributors to the EasyTexture project <https://github.com/EasyScience/EasyTextureApp>
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import QtWebEngine 1.10
8+
9+
import easyApp.Gui.Elements 1.0 as EaElements
10+
11+
Rectangle {
12+
id: container
13+
14+
property var z3dValues: [[1, 20, 30], [20, 1, 60], [30, 60, 1]]
15+
16+
property int pageLoading: chartView.loading
17+
18+
WebEngineView {
19+
id: chartView
20+
21+
anchors.fill: parent
22+
anchors.bottomMargin: 20
23+
anchors.topMargin: 18
24+
anchors.leftMargin: 15
25+
anchors.rightMargin: 15
26+
27+
backgroundColor: parent.color
28+
29+
url: 'ChartTemplateHeatmap2dPlotly.html'
30+
31+
onContextMenuRequested: {
32+
request.accepted = true
33+
}
34+
35+
onLoadingChanged: {
36+
if (loadRequest.status === WebEngineView.LoadSucceededStatus) {
37+
setZ3dValues()
38+
redrawPlot()
39+
}
40+
}
41+
42+
onWidthChanged: reload()
43+
onHeightChanged: reload()
44+
45+
}
46+
47+
// Logic
48+
49+
function setZ3dValues() {
50+
//chartView.runJavaScript(`setZ3dValues(${JSON.stringify(z3dValues)})`, function(result) { console.log(result); })
51+
chartView.runJavaScript(`setZ3dValues(${JSON.stringify(z3dValues)})`)
52+
}
53+
54+
function redrawPlot() {
55+
chartView.runJavaScript(`redrawPlot()`)
56+
}
57+
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// SPDX-FileCopyrightText: 2022 EasyTexture contributors
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
// © 2022 Contributors to the EasyTexture project <https://github.com/EasyScience/EasyTextureApp>
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import QtWebEngine 1.10
8+
9+
import easyApp.Gui.Elements 1.0 as EaElements
10+
11+
Rectangle {
12+
id: container
13+
14+
property var xArrayValues: [0, 1, 2]
15+
property var yArrayValues: [1.0, 0.0, 0.5]
16+
property int xyArraysLength: xArrayValues.length
17+
18+
property string xAxisTitle: 'X axis'
19+
property string yAxisTitle: 'Y axis'
20+
21+
property int pageLoading: chartView.loading
22+
23+
WebEngineView {
24+
id: chartView
25+
26+
anchors.fill: parent
27+
anchors.bottomMargin: 20
28+
anchors.topMargin: 18
29+
anchors.leftMargin: 15
30+
anchors.rightMargin: 15
31+
32+
backgroundColor: parent.color
33+
34+
url: 'ChartTemplateSimple1dPlotly.html'
35+
36+
onContextMenuRequested: {
37+
request.accepted = true
38+
}
39+
40+
onLoadingChanged: {
41+
if (loadRequest.status === WebEngineView.LoadSucceededStatus) {
42+
setXAxisTitle()
43+
setYAxisTitle()
44+
setXArrayValues()
45+
setYArrayValues()
46+
redrawPlot()
47+
}
48+
}
49+
50+
onWidthChanged: reload()
51+
onHeightChanged: reload()
52+
53+
}
54+
55+
// Logic
56+
57+
function setXAxisTitle() {
58+
//chartView.runJavaScript(`setXAxisTitle(${xAxisTitle})`, function(result) { console.log(result); })
59+
chartView.runJavaScript(`setXAxisTitle(${JSON.stringify(xAxisTitle)})`)
60+
}
61+
62+
function setYAxisTitle() {
63+
chartView.runJavaScript(`setYAxisTitle(${JSON.stringify(yAxisTitle)})`)
64+
}
65+
66+
function setXArrayValues(newValues) {
67+
//chartView.runJavaScript(`setXArrayValues(${JSON.stringify(xArrayValues)})`, function(result) { console.log(result); })
68+
chartView.runJavaScript(`setXArrayValues(${JSON.stringify(xArrayValues)})`)
69+
}
70+
71+
function setYArrayValues(newValues) {
72+
//chartView.runJavaScript(`setYArrayValues(${JSON.stringify(yArrayValues)})`, function(result) { console.log(result); })
73+
chartView.runJavaScript(`setYArrayValues(${JSON.stringify(yArrayValues)})`)
74+
}
75+
76+
function redrawPlot() {
77+
chartView.runJavaScript(`redrawPlot()`)
78+
}
79+
80+
function redrawPlotWithYAnimation() {
81+
chartView.runJavaScript(`redrawPlotWithYAnimation()`)
82+
}
83+
84+
}

0 commit comments

Comments
 (0)