Skip to content

Commit

Permalink
added HTMLTables to project. new examples, removed css color
Browse files Browse the repository at this point in the history
  • Loading branch information
cecoeco committed Jul 28, 2024
1 parent d901c13 commit 70328dd
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ julia = "1"

[extras]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
HTMLTables = "b1afcece-b80e-4563-b90e-36b4cc56d3fa"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"

[targets]
test = ["Test", "CSV", "XLSX"]
test = ["Test", "CSV", "HTMLTables", "XLSX"]
116 changes: 114 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,119 @@ PRISMA.jl is a Julia package and [web application]() for generating checklists a
using Pkg; Pkg.add("PRISMA")
```

## :computer: Examples
## Examples

The `flow_diagram_df` function is needed to create flow diagram. It has three columns: `"box_num"`, `"box_lab"`, `"results"`. The `"box_num"` column determines what box the data belongs to. A `"box_label"` would be the title of the box or an exclusion reason, and the `"results"` is the number of records that was excluded, so it must have an adjacent `"box_label"`. This `DataFrame` that is returned from `flow_diagram_df` can be saved as a data file then be read back into a Julia program using the `DataFrames` package or it can be directly modified in a Julia program using functions from `DataFrames` like `push!`:

```julia
using PRISMA: flow_diagram
using DataFrames: DataFrame, push!
using CSV, HTMLTables, XLSX

df::DataFrame = flow_diagram_df()

# adding new Databases
push!(df, (8, "Database or Register 4", 150))
push!(df, (8, "Database or Register 5", 121))

# adding new reasons for exclusion
push!(df, (15, "Reason 4", 20))
push!(df, (15, "Reason 5", 10))
push!(df, (15, "Reason 6", 03))

println(df)

# export the data as a CSV to edit then read it back to a DataFrame
csv_path::String = "flow_diagram.csv"
CSV.write(csv_path, df)
csv_df::DataFrame = CSV.read(csv_path, DataFrame)

println(csv_df)

# export the data as a HTML table to edit then read it back to a DataFrame
html_path::String = "flow_diagram.html"
HTMLTables.write(html_path, df)
html_df::DataFrame = HTMLTables.read(html_path, DataFrame)

println(html_df)

# export the data as a Excel spreadsheet to edit then read it back to a DataFrame
xlsx_path::String = "flow_diagram.xlsx"
sheetname::String = "flow_diagram"
XLSX.writetable(xlsx_path, sheetname => df)
xlsx_df::DataFrame = DataFrame(XLSX.readtable(xlsx_path, sheetname))

println(xlsx_df)
```

The updated `DataFrames` either it be from a `.csv`, `.html`, `.json`, or `.xlsx` can be loaded into the `flow_diagram` function to create the `FlowDiagram` object which can be plotted using the `Base.show`, and `Base.Multimedia.display` function. The `Base.Multimedia.display` defaults to plotting the `FlowDiagram` as a `SVG` and uses the Julia plotting plane if using VSCode. The format that `Base.show` returns is depended on the mime type represented as `Mime` in Julia. `Base.show` can use an mime type that Graphviz supports through the `Graphviz_jll` binary. The `text/vnd.graphviz` and `text/plain` mimes prints the `.gv` to `IO`:

```julia
using PRISMA: FlowDiagram, flow_diagram

fd::FlowDiagram = flow_diagram()

show(stdout, "text/vnd.graphviz", fd)
show(stdout, "text/plain", fd)
show(stdout, "application/pdf", fd)
show(stdout, "image/png", fd)
show(stdout, "image/svg+xml", fd)

display(fd)
```

The `FlowDiagram` can be saved as any format support by `Graphviz_jll` using the `flow_diagram_save` the only catch is the file path should end with the extension of the desired format:

```julia
using PRISMA: FlowDiagram, flow_diagram

fd::FlowDiagram = flow_diagram()

# saves that flow diagram as an SVG
flow_diagram_save("flow_diagram.svg", fd)

# saves that flow diagram as a PNG
flow_diagram_save("flow_diagram.png", fd)
```

The look of the `FlowDiagram` can be edited assigning new values to each of the following keyword arguments of the `flow_diagram` function: `arrow_color`, `arrow_head`, `arrow_size`, `arrow_width`, `background_color`, `border_color`, `border_style`, `border_width`, `borders`, `font`, `font_color`, `font_size`, `grayboxes`, `grayboxes_color`, `other_methods`, `previous_studies`, `side_boxes`, `side_boxes_borders`, `side_boxes_color`, `top_boxes`, `top_boxes_borders`, `top_boxes_color`. The amount of arguments allows for the `FlowDiagram` to be high customizable and variable:

```julia
using PRISMA: FlowDiagram, flow_diagram, flow_diagram_save

# flow diagram with default styling
example_01::FlowDiagram = flow_diagram()

# flow diagram with custom styling
example_02::FlowDiagram = flow_diagram(
arrow_color="#111111",
arrow_head="Vee",
arrow_width=2,
border_color="#111111",
border_width=2,
font="Helvetica",
font_color="#111111",
font_size=10,
grayboxes=false,
previous_studies=false,
side_boxes_borders=true,
side_boxes_color="white",
top_boxes_borders=true,
top_boxes_color="white"
)

flow_diagram_save("example_01.svg", example_01)
flow_diagram_save("example_02.svg", example_02)

```

The flow diagram with default styling:

![flow diagram with default styling](docs/src/assets/figure.svg)

The flow diagram with custom styling:

![flow diagram with custom styling](docs/src/assets/figure.svg)

Creating a completed checklist from a paper and saving the results to a spreadsheet:

Expand Down Expand Up @@ -56,7 +168,7 @@ clist_template::DataFrame = checklist_df()

println(clist_template)

writetable("PRISMA_checklist.csv", "sheet_1" => clist_template)
writetable("PRISMA_checklist.xlsx", "sheet_1" => clist_template)
```

The `DataFrame` that is created from the `checklist_df` function can also be edited within a Julia program using functions from the `DataFrames` package:
Expand Down
1 change: 0 additions & 1 deletion app/frontend/src/assets/css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ header {
font-size: .85rem;
top: 0;
z-index: 1;
color: var(--text-color-1);
background-color: var(--background-color-1);
width: 100%;
padding: 0 1%;
Expand Down

0 comments on commit 70328dd

Please sign in to comment.