Editable plot width

Everything related to the development of modules in jamovi

by max » Tue Oct 09, 2018 4:04 am

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!
max
 
Posts: 5
Joined: Sun Oct 07, 2018 5:33 pm

by jonathon » Tue Oct 09, 2018 5:29 am

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
User avatar
jonathon
 
Posts: 869
Joined: Fri Jan 27, 2017 10:04 am

by max » Tue Oct 09, 2018 5:51 am

I defined the Width as an integer, but the error remains.

- name: PlotWidth
title: Width
type: Integer
default: 800
max
 
Posts: 5
Joined: Sun Oct 07, 2018 5:33 pm

by jonathon » Tue Oct 09, 2018 6:01 am

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
User avatar
jonathon
 
Posts: 869
Joined: Fri Jan 27, 2017 10:04 am

by max » Tue Oct 09, 2018 8:01 am

Works like a charm!
Cheers
Max
max
 
Posts: 5
Joined: Sun Oct 07, 2018 5:33 pm


Return to Module development