@@ -192,7 +192,6 @@ loonGlyphGrob.image <- function(widget, x, glyph_info) {
192
192
tcl_img_i <- gh [' images' ][glyph_info $ index ]
193
193
size_i <- glyph_info $ size
194
194
195
-
196
195
# get the scaled_image
197
196
height <- as.numeric(tcl(" image" , " height" , tcl_img_i ))
198
197
width <- as.numeric(tcl(" image" , " width" , tcl_img_i ))
@@ -211,10 +210,8 @@ loonGlyphGrob.image <- function(widget, x, glyph_info) {
211
210
212
211
tcl(" image" , " delete" , scaled_img )
213
212
214
-
215
-
216
- width_p = unit(image_w / 40 , " cm" )
217
- height_p = unit(image_h / 40 , " cm" )
213
+ width_p <- unit(as_r_image_size(image_w ), " mm" )
214
+ height_p <- unit(as_r_image_size(image_h ), " mm" )
218
215
219
216
gTree(
220
217
children = gList(
@@ -274,9 +271,7 @@ loonGlyphGrob.pointrange <- function(widget, x, glyph_info) {
274
271
gp = gpar(col = glyph_info $ color ,
275
272
cex = as_r_point_size(glyph_info $ size )),
276
273
pch = if (showArea ) 21 else 19 ,
277
- name = " point"
278
-
279
- ),
274
+ name = " point" ),
280
275
linesGrob(x = rep(glyph_info $ x , 2 ),
281
276
y = unit(c(gh [' ymin' ][glyph_info $ index ],
282
277
gh [' ymax' ][glyph_info $ index ]),
@@ -299,8 +294,8 @@ loonGlyphGrob.polygon <- function(widget, x, glyph_info) {
299
294
color <- glyph_info $ color
300
295
size <- glyph_info $ size
301
296
302
- poly_x <- gh [' x' ][[glyph_info $ index ]] * as_r_polygonGlyph_size (size )
303
- poly_y <- - gh [' y' ][[glyph_info $ index ]] * as_r_polygonGlyph_size (size )
297
+ poly_x <- gh [' x' ][[glyph_info $ index ]] * as_r_polygon_size (size )
298
+ poly_y <- - gh [' y' ][[glyph_info $ index ]] * as_r_polygon_size (size )
304
299
305
300
x <- glyph_info $ x
306
301
y <- glyph_info $ y
@@ -328,15 +323,7 @@ loonGlyphGrob.polygon <- function(widget, x, glyph_info) {
328
323
}
329
324
}
330
325
331
- as_r_polygonGlyph_size <- function (size ){
332
- if (is.numeric(size )) {
333
- # trial and error to choose scale for size
334
- size <- size / 1.25
335
- size [size < 0.01 ] <- 0.01
336
- size
337
- }
338
- size
339
- }
326
+
340
327
341
328
loonGlyphGrob.serialaxes <- function (widget , x , glyph_info ) {
342
329
@@ -372,8 +359,8 @@ loonGlyphGrob.serialaxes <- function(widget, x, glyph_info) {
372
359
ypos <- glyph_info $ y
373
360
374
361
if (axesLayout == " parallel" ){
375
- scaleX <- as_r_serialaxesGlyph_size (size , " x" , " parallel" )
376
- scaleY <- as_r_serialaxesGlyph_size (size , " y" , " parallel" )
362
+ scaleX <- as_r_serialaxes_size (size , " x" , " parallel" )
363
+ scaleY <- as_r_serialaxes_size (size , " y" , " parallel" )
377
364
378
365
lineXaxis <- seq(- 0.5 * scaleX , 0.5 * scaleX , length.out = dimension )
379
366
lineYaxis <- (scaledData [glyph_info $ index , ] - 0.5 ) * scaleY
@@ -418,8 +405,8 @@ loonGlyphGrob.serialaxes <- function(widget, x, glyph_info) {
418
405
), name = paste0(" serialaxes_glyph: parallel " , glyph_info $ index )
419
406
)
420
407
} else {
421
- scaleX <- as_r_serialaxesGlyph_size (size , " x" , " radial" )
422
- scaleY <- as_r_serialaxesGlyph_size (size , " y" , " radial" )
408
+ scaleX <- as_r_serialaxes_size (size , " x" , " radial" )
409
+ scaleY <- as_r_serialaxes_size (size , " y" , " radial" )
423
410
424
411
angle <- seq(0 , 2 * pi , length.out = dimension + 1 )[1 : dimension ]
425
412
radialxaxis <- scaleX * scaledData [glyph_info $ index ,] * cos(angle )
@@ -541,21 +528,3 @@ get_glyph_scale_info <- function(widget){
541
528
names(scaleInfo ) <- paste(name , unique_glyph )
542
529
scaleInfo
543
530
}
544
-
545
-
546
- as_r_serialaxesGlyph_size <- function (size , coord , axesLayout ){
547
- if (is.numeric(size )) {
548
- # trial and error to choose scale for size
549
- if (axesLayout == " radial" ) {
550
- size <- sqrt(size ) * 5
551
- } else if (axesLayout == " parallel" ){
552
- if (coord == " x" ) {
553
- size <- sqrt(size ) * 6.4
554
- } else if (coord == " y" ){
555
- size <- sqrt(size ) * 3.2
556
- } else size <- NA
557
- } else size <- NA
558
- size [size == 0 ] <- 0.01
559
- }
560
- size
561
- }
0 commit comments