Skip to content

Commit

Permalink
updates for v0.1.5 (#24)
Browse files Browse the repository at this point in the history
* chore: upgrade graphic-walker to 0.4.70

* feat: new param `toolbarExclude` to specify tools to be excluded

* docs: add instruction for dev

* bump version to 0.1.5
  • Loading branch information
bruceyyu authored Aug 26, 2024
1 parent ef8fa98 commit 4e8e913
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 198 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: GWalkR
Title: Interactive Exploratory Data Analysis Tool
Version: 0.1.4
Version: 0.1.5
Authors@R: c(
person("Yue", "Yu", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9302-0793")),
Expand All @@ -10,7 +10,7 @@ Description: Simplify your R data analysis and data visualization workflow by tu
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
URL: https://github.com/Kanaries/GWalkR/
BugReports: https://github.com/Kanaries/GWalkR/issues
Imports:
Expand Down
7 changes: 4 additions & 3 deletions R/gwalkr.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' )}
#' @param visConfig An optional config string to reproduce your chart. You can copy the string by clicking "export config" button on the GWalkR interface.
#' @param visConfigFile An optional config file path to reproduce your chart. You can download the file by clicking "export config" button then "download" button on the GWalkR interface.
#' @param toolbarExclude An optional list of strings to exclude the tools from toolbar UI. However, Kanaries brand info is not allowed to be removed or changed unless you are granted with special permission.
#'
#' @return An \code{htmlwidget} object that can be rendered in R environments
#'
Expand All @@ -27,7 +28,7 @@
#' gwalkr(mtcars)
#'
#' @export
gwalkr <- function(data, lang = "en", dark = "light", columnSpecs = list(), visConfig = NULL, visConfigFile = NULL) {
gwalkr <- function(data, lang = "en", dark = "light", columnSpecs = list(), visConfig = NULL, visConfigFile = NULL, toolbarExclude = list()) {
if (!is.data.frame(data)) stop("data must be a data frame")
if (!is.null(visConfig) && !is.null(visConfigFile)) stop("visConfig and visConfigFile are mutually exclusive")
lang <- match.arg(lang, choices = c("en", "ja", "zh"))
Expand All @@ -43,9 +44,9 @@ gwalkr <- function(data, lang = "en", dark = "light", columnSpecs = list(), visC
dataSource = jsonlite::toJSON(data),
rawFields = rawFields,
i18nLang = lang,
hideDataSourceConfig = TRUE,
visSpec = visConfig,
dark = dark
dark = dark,
toolbarExclude = toolbarExclude
)

# create widget
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,18 @@ gwalkr(iris)

Showcase your data insights with editable and explorable charts on a webpage ([example](https://bruceyyu.github.io/show/tidytuesday_etymology.nb.html))!

<img width="700" alt="image" src="https://github.com/bruceyyu/GWalkR/assets/33870780/4798367c-0dd4-4ad3-b25b-7ea48b79205a">
<img width="700" alt="image" src="https://github.com/bruceyyu/GWalkR/assets/33870780/4798367c-0dd4-4ad3-b25b-7ea48b79205a">

## Development
We encourage developers from the amazing open-source community to help improve this R package!

Because the built web library is not tracked by git, the source code here is not directly runnable.
Please follow the steps below to run the source code on your own device:

1. Run `git clone https://github.com/Kanaries/GWalkR.git` to clone this repository.
2. Go to `/web_app` and `yarn install`.
3. You can now implement your features either in the web app by changing the TypeScript code, or in the R scripts under `/R`.
4. Run `yarn run build` to build the web app, and make sure the built library can be found under `/inst/htmlwidgets/lib/`.
5. In R Studio, run `devtools::load_all("{DIR_OF_GWALKR}")` to load the package (make sure you've removed the installed GWalkR from CRAN before that).

For more information about R package development, please refer to this book, [*R Packages*](https://r-pkgs.org/).
45 changes: 29 additions & 16 deletions docs/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,45 @@ status](https://www.r-pkg.org/badges/version/GWalkR)](https://CRAN.R-project.org

### 安装 GWalkR

#### 通过 CRAN 安装 (推荐)

```R
install.packages("GWalkR")
library(GWalkR)
```

#### 通过运行R脚本安装

如果您已在R中安装了`devtools`,您可以在脚本中运行以下R代码来下载。

```R
devtools::install_url("https://kanaries-app.s3.ap-northeast-1.amazonaws.com/oss/gwalkr/GWalkR_latest.tar.gz")
```

#### 通过下载 .tar.gz 文件包安装

或者,从[这个链接](https://kanaries-app.s3.ap-northeast-1.amazonaws.com/oss/gwalkr/GWalkR_latest.tar.gz)中下载包 GWalkR_latest.tar.gz。
打开 R Studio,点击 "Packages" 窗口中的 "Install",然后在 "Install from" 中选择 "Package Archive File (.tgz; .tar.gz)"。然后,选择您的文件系统中的下载好的包,最后点击"Install"。

### 用一行代码开始您的数据探索吧

```R
library(GWalkR)
data(iris)
gwalkr(iris)
```

<img width="1437" alt="image" src="https://github.com/Bruceshark/GWalkR/assets/33870780/718d8ff6-4ad5-492d-9afb-c4ed67573f51">

## 主要功能
### 查看数据概览
<img width="700" alt="image" src="https://github.com/bruceyyu/GWalkR/assets/33870780/67131cfa-a25b-44ae-90a0-95902ea5edb1">

### 通过简单的拖拽操作创建数据可视化
<img width="700" alt="image" src="https://github.com/Bruceshark/GWalkR/assets/33870780/718d8ff6-4ad5-492d-9afb-c4ed67573f51">

### 发现有趣的数据点?使用笔刷功能进一步分析!
<img width="700" alt="image" src="https://github.com/bruceyyu/GWalkR/assets/33870780/8033885d-3699-4f50-84e1-2201b3846b5a">

### 为R Notebook(如R Markdown)提供强大支持

在网页上展示可编辑和交互的图表,让您的数据洞察更加生动 [(示例)]((https://bruceyyu.github.io/show/tidytuesday_etymology.nb.html))

<img width="700" alt="image" src="https://github.com/bruceyyu/GWalkR/assets/33870780/4798367c-0dd4-4ad3-b25b-7ea48b79205a">

## 开发指南
我们欢迎来自开源社区的开发者帮助改进此R包!

由于构建的Web库不被Git追踪,这里的源代码无法直接运行。请按以下步骤在您的设备上运行源代码:

1. 运行 `git clone https://github.com/Kanaries/GWalkR.git` 克隆此仓库。
2. 进入 `/web_app` 并运行 `yarn install`
3. 您可以在TypeScript代码的Web应用或 `/R` 目录下的R脚本中实现您的功能。
4. 运行 `yarn run build` 构建Web应用,并确保构建后的库位于 `/inst/htmlwidgets/lib/` 下。
5. 在R Studio中运行 `devtools::load_all("{GWalkR的路径}")` 来加载包(确保您已经卸载了从CRAN安装的GWalkR)。

如需了解更多R包开发的相关信息,请参考 [*R Packages*](https://r-pkgs.org/) 这本书。
5 changes: 4 additions & 1 deletion man/gwalkr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions web_app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<title>GWalkR App</title>
</head>
<body>
<div id="rwalker-app"></div>
<div id="gwalkr-app"></div>
<script type="module">
import GWalker from './src/index';
GWalker({}, "rwalker-app");
import GWalkR from './src/index';
GWalkR({}, "gwalkr-app");
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion web_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@kanaries/graphic-walker": "^0.4.61",
"@kanaries/graphic-walker": "^0.4.70",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
Expand Down
18 changes: 9 additions & 9 deletions web_app/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import { createRoot } from "react-dom/client";
import { observer } from "mobx-react-lite";
import { IAppProps } from "./interfaces";
import { GraphicWalker } from "@kanaries/graphic-walker";
import type { VizSpecStore } from '@kanaries/graphic-walker/store/visualSpecStore';
import type { VizSpecStore } from "@kanaries/graphic-walker/store/visualSpecStore";
import { getExportTool } from "./tools/exportTool";
import CodeExportModal from "./components/codeExportModal";
import { StyleSheetManager } from "styled-components";
import tailwindStyle from "tailwindcss/tailwind.css?inline";
import formatSpec from "./utils/formatSpec";

const App: React.FC<IAppProps> = observer((propsIn) => {
const { dataSource, visSpec, rawFields, ...props } = propsIn;
const storeRef = React.useRef<VizSpecStore|null>(null);
const { dataSource, visSpec, rawFields, toolbarExclude, ...props } = propsIn;
const storeRef = React.useRef<VizSpecStore | null>(null);

const specList = visSpec ? formatSpec(JSON.parse(visSpec) as any[], rawFields) : undefined
const specList = visSpec ? formatSpec(JSON.parse(visSpec) as any[], rawFields) : undefined;
const [exportOpen, setExportOpen] = useState(false);

const exportTool = getExportTool(setExportOpen);

const tools = [exportTool];

const toolbarConfig = {
exclude: ["export_code"],
exclude: toolbarExclude ? [...toolbarExclude, "export_code"] : ["export_code"],
extra: tools,
};
return (
Expand All @@ -35,7 +35,7 @@ const App: React.FC<IAppProps> = observer((propsIn) => {
);
});

const GWalker = (props: IAppProps, id: string) => {
const GWalkR = (props: IAppProps, id: string) => {
const container = document.getElementById(id);
if (container) {
const shadowRoot = container.attachShadow({ mode: "open" });
Expand All @@ -52,10 +52,10 @@ const GWalker = (props: IAppProps, id: string) => {
</StyleSheetManager>
);
}
// If you want to execute GWalker after the document has loaded, you can do it here.
// If you want to execute GWalkR after the document has loaded, you can do it here.
// But remember, you will need to provide the 'props' and 'id' parameters.
// GWalker(someProps, someId);
// GWalkR(someProps, someId);
// });
};

export default GWalker;
export default GWalkR;
1 change: 1 addition & 0 deletions web_app/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface IAppProps {
specType?: string;
dataSource: IRow[];
rawFields: IMutField[];
toolbarExclude: string[];
}
Loading

0 comments on commit 4e8e913

Please sign in to comment.