Skip to content

Commit b119079

Browse files
Make x-axis choosable in CSV-plot
1 parent 0502ae6 commit b119079

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

viplab-standalone-frontend-vue/src/components/csv-plots/CsvPlot.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,44 @@ export default {
131131
keys.forEach(element => obj[element].push(row[element]));
132132
}
133133
134+
let xkey = keys[0];
135+
if (this.labelProp.key !== undefined) {
136+
if (keys[0] !== this.labelProp.key) {
137+
xkey = this.labelProp.key
138+
}
139+
}
140+
141+
console.log(xkey)
142+
134143
// multiply x-axis by factor if given
135144
if (this.labelProp.factor !== undefined) {
136-
for (let j = 0; j < obj[(keys[0])].length; j++) {
137-
obj[(keys[0])][j] = obj[(keys[0])][j] * this.labelProp.factor
145+
for (let j = 0; j < obj[(xkey)].length; j++) {
146+
obj[(xkey)][j] = obj[(xkey)][j] * this.labelProp.factor
138147
}
139148
}
140149
150+
delete keys[xkey]
151+
141152
// create traces to be rendered later; the first column is always x; the others are ys
142-
for (var k = 1; k < keys.length; k++) {
153+
for (var k = 0; k < keys.length; k++) {
143154
if (this.datasetProp.key) {
144155
// multiply y-axis by factor if given
145156
if(keys[k] === this.datasetProp.key) {
146157
if (this.datasetProp.factor !== undefined) {
147-
for (let j = 0; j < obj[(keys[0])].length; j++) {
158+
for (let j = 0; j < obj[(xkey)].length; j++) {
148159
obj[(keys[k])][j] = obj[(keys[k])][j] * this.datasetProp.factor
149160
}
150161
}
151162
let trace = {
152-
x: obj[(keys[0])],
163+
x: obj[(xkey)],
153164
y: obj[(keys[k])],
154165
name: this.datasetProp.label
155166
}
156167
traces.push(trace);
157168
}
158169
} else {
159170
let trace = {
160-
x: obj[(keys[0])],
171+
x: obj[(xkey)],
161172
y: obj[(keys[k])],
162173
name: keys[k]
163174
}
@@ -176,7 +187,7 @@ export default {
176187
title: title,
177188
xaxis: {
178189
title: {
179-
text: this.labelProp.label || keys[0]
190+
text: this.labelProp.label || xkey
180191
},
181192
tickformat: xformat
182193
},

viplab-standalone-frontend-vue/src/input/workshop-snakemake-example.computation-template.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@
1313
{
1414
"basename": "plot_data",
1515
"xlabel": {
16-
"key": "function",
17-
"label": "Function"
16+
"key": "arc_length",
17+
"label": "arc_length"
1818
},
1919
"plots": [
2020
{
21-
"key": "vtkValidPointMask",
22-
"label": "vtkValidPointMask"
23-
},
24-
{
25-
"key": "arc_length",
26-
"label": "arc_lenght"
21+
"key": "function",
22+
"label": "function"
2723
}
2824
]
2925
}

0 commit comments

Comments
 (0)