Everything related to the development of modules in jamovi
-
max
- Posts: 5
- Joined: Sun Oct 07, 2018 5:33 pm
Post
by max »
Hi again,
is it possible to modify the width of a plot using a TextBox?
I have defined a text box in name.u.yaml:
Code: Select all
- type: TextBox
name: PlotWidth
format: number
inputPattern: '[0-9]+'
In the name.r.yaml I added:
Code: Select all
- name: plot
title: Plot
type: Image
width: (PlotWidth)
height: 400
renderFun: .plot
This results in the following error:
Code: Select all
Unable to compile 'rulr.r.yaml':
results.items[1].width is not of a type(s) integer
I guess the "width" is saved as a string in the text box. Is there an easy way to change this?
Thanks in advance!
-
jonathon
- Posts: 2613
- Joined: Fri Jan 27, 2017 10:04 am
Post
by jonathon »
the .a.yaml file is key here. the option 'PlotWidth' needs to be of type 'Integer'
if you get stuck, commit it to github and we'll take a look.
jonathon
-
max
- Posts: 5
- Joined: Sun Oct 07, 2018 5:33 pm
Post
by max »
I defined the Width as an integer, but the error remains.
- name: PlotWidth
title: Width
type: Integer
default: 800
-
jonathon
- Posts: 2613
- Joined: Fri Jan 27, 2017 10:04 am
Post
by jonathon »
ah, i think that a plot width doesn't allow data binding, so you'll have to do it manually.
add a `.init()` function beside your `.run()` method, and in that add something like:
self$results$plot$setSize(self$options$width, self$options$height)
cheers
jonathon
-
max
- Posts: 5
- Joined: Sun Oct 07, 2018 5:33 pm
Post
by max »
Works like a charm!
Cheers
Max