Skip to content
This repository was archived by the owner on Apr 10, 2022. It is now read-only.

Commit b65e2e0

Browse files
committed
reformat
1 parent dcb3b5e commit b65e2e0

File tree

7 files changed

+65
-72
lines changed

7 files changed

+65
-72
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
test-plugin*
66
ezcox
77
pcatools
8+
test*

test_ezcox.R examples/ezcox.R

File renamed without changes.

examples/helloworld.R

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# 函数参数除了 default,其他直接转换 hiplot 前端支持的所有选项
2+
#
3+
# @hiplot start
4+
# @appname helloworld
5+
# @apptitle
6+
# Hiplot Hello World
7+
# Hiplot 示例插件
8+
# @target basic
9+
# @tag test dotplot
10+
# @author your name
11+
# @url your project link
12+
# @citation any reference you should link to
13+
# @version 0.1.0
14+
# @release 2021-01-01
15+
# @description
16+
# en: One sentence to describe this plugin.
17+
# zh: 插件一段话简单介绍。
18+
# @main helloworld
19+
# @library ggplot2 readr
20+
# @param data export::data::hiplot-textarea::{"default": "data.txt", "required": true}
21+
# en: Data Table
22+
# zh: 数据表
23+
# @param x export::dataArg::data::{"index":1, "default": "mpg", "required": true}
24+
# en: X Axis Variable
25+
# zh: X 轴变量
26+
# @param y export::dataArg::data::{"index":2, "default": "vs", "blackItems": "carb", "required": false}
27+
# en: X Axis Variable
28+
# zh: Y 轴变量
29+
# @param size export::extra::slider::{"default":2, "min":0.5, "max":5, "step":0.5, "class":"col-12"}
30+
# en: Dot Size
31+
# zh: 点大小
32+
# @param add_line export::extra::switch::{"default": true, "class":"col-12"}
33+
# en: Add Line
34+
# zh: 添加线图
35+
# @return ggplot::["pdf", "png"]::{"title": "A test plot", "width":4, "height": 4, "theme": "theme_bw"}
36+
# @data
37+
# # You can write the code to generate the example data
38+
# # 'data.txt' described in parameter data, or you can
39+
# # omit this tag and submit prepared data files.
40+
# # File size <100Kb is recommended.
41+
# # 此处可以编写生成示例数据(建议小于 100Kb)的代码
42+
# # 示例数据文件需要跟数据表格参数对应起来
43+
# # 或者忽略该标签,提交已经准备好的示例数据
44+
# library(readr)
45+
# data("mtcars")
46+
# write_tsv(mtcars, "data.txt")
47+
# @hiplot end
48+
49+
library(ggplot2)
50+
helloworld <- function(data, x, y, size = 2, add_line = TRUE) {
51+
if (y == "") stop("y must be provided!")
52+
p <- ggplot(data, aes_string(x = x, y = y))
53+
p <- p + geom_point(size = size)
54+
if (add_line) {
55+
p <- p + geom_line()
56+
}
57+
# Here export a ggplot object
58+
# Or the whole main function generate a basic R plot
59+
return(p)
60+
}
File renamed without changes.
File renamed without changes.

hisub.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ collect_params <- function(x) {
372372
}
373373
if (length(fpath) > 0) {
374374
edata <- read_lines(file.path(outdir, fpath))
375-
esize <- file.info("app.R")$size / 1024 # Kb
375+
esize <- file.info(file.path(outdir, fpath))$size / 1024 # Kb
376376
if (esize > 500) {
377377
edata <- edata[sample(seq_len(edata), round(250 * length(edata / esize)))]
378378
}
@@ -493,16 +493,16 @@ shifter <- function(x, n = -1) {
493493
if (n == 0) x else c(tail(x, -n), head(x, n))
494494
}
495495

496-
if (length(a$params$params_data) > 0) {
496+
if (length(unlist(a$params$params_data)) > 0) {
497497
json_data$params$config$data <- a$params$params_data
498498
json_data$params$config <- shifter(json_data$params$config)
499499
}
500-
if (length(a$params$params_textarea) > 0) {
500+
if (length(unlist(a$params$params_textarea)) > 0) {
501501
json_data$params$textarea <- a$params$params_textarea
502502
json_data$params <- shifter(json_data$params)
503503
}
504504

505-
if (length(a$params$example_data) > 0) {
505+
if (length(unlist(a$params$example_data)) > 0) {
506506
json_data$exampleData$data <- a$params$example_data
507507
json_data$exampleData <- shifter(json_data$exampleData)
508508
}

test.R

-68
This file was deleted.

0 commit comments

Comments
 (0)