diff --git a/Project.toml b/Project.toml index 89e9707..6c1d7dd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PRISMA" uuid = "7b67a8d2-c4f5-4933-b91c-0fc427024db5" authors = ["Ceco Elijah Maples ", "PRISMA.jl Contributors"] -version = "0.0.7" +version = "0.0.8" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" diff --git a/README.md b/README.md index ca5fe6f..dd9ff0f 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,16 @@ create, plot, and save a flow diagram: ```julia -using PRISMA: FlowDiagram, flow_diagram, flow_diagram_save +using PRISMA: flow_diagram, flow_diagram_save -fd::FlowDiagram = flow_diagram() - -display(fd) - -flow_diagram_save("flow_diagram.svg", fd) +flow_diagram_save("example-01.svg", flow_diagram()) ``` output: ![flow diagram](docs/src/assets/flow_diagram.svg) -**Citing:** please consider citing PRISMA.jl and giving the GitHub repository a star, if possible. +**Citing:** please consider citing `PRISMA.jl` and giving the GitHub repository a star, if possible. The citation information may be found in the [`CITATION.bib`](CITATION.bib) file within the repository diff --git a/src/PRISMA.jl b/src/PRISMA.jl index 517dbe4..efa6f77 100644 --- a/src/PRISMA.jl +++ b/src/PRISMA.jl @@ -39,20 +39,14 @@ import Base.Multimedia.display, Base.show export # re-exports DataFrame, display, show, - # checklist.jl - checklist_df, checklist_template, - checklist_read, checklist, - Checklist, checklist_save, - + checklist_df, checklist_template, checklist_read, checklist, Checklist, checklist_save, # flow_diagram.jl - flow_diagram_df, flow_diagram_template, - flow_diagram_read, flow_diagram, - FlowDiagram, flow_diagram_save + flow_diagram_df, flow_diagram_template, flow_diagram_read, flow_diagram, FlowDiagram, flow_diagram_save -include("checklist_docstrings.jl") include("checklist.jl") -include("flow_diagram_docstrings.jl") include("flow_diagram.jl") +display(flow_diagram()) + end # module diff --git a/src/checklist.jl b/src/checklist.jl index b65bccb..59b4989 100644 --- a/src/checklist.jl +++ b/src/checklist.jl @@ -1,3 +1,5 @@ +include("checklist_docstrings.jl") + """ $docstring_checklist_df """ diff --git a/src/flow_diagram.jl b/src/flow_diagram.jl index 2bb1169..f52d9d4 100644 --- a/src/flow_diagram.jl +++ b/src/flow_diagram.jl @@ -1,3 +1,5 @@ +include("flow_diagram_docstrings.jl") + """ $docstring_flow_diagram_df """ @@ -91,13 +93,29 @@ function group_labels(df::DataFrame)::DataFrame labels::Vector{String} = String[] for row in Base.eachrow(g) - text::String = row.box_num in TOP_BOXES || row.box_num in SIDE_BOXES ? "$(row.box_text)" : row.box_text + text::String = if row.box_num in TOP_BOXES || row.box_num in SIDE_BOXES + "$(row.box_text)" + else + row.box_text + end + result::String = Base.ismissing(row.result) ? "" : "(n = $(row.result))" - wrapped_text::String = row.box_num in TOP_BOXES || row.box_num in SIDE_BOXES ? text : wrap_text(text) + wrapped_text::String = if row.box_num in TOP_BOXES || row.box_num in SIDE_BOXES + text + else + wrap_text(text) + end + wrapped_result::String = wrap_text(result) - label::String = Base.ismissing(row.result) ? wrapped_text : Base.string(wrapped_text, "
", wrapped_result) + label::String = if Base.ismissing(row.result) + wrapped_text + elseif row.box_num in [7, 9, 10, 11, 12, 13, 14, 16, 17, 19, 20, 21] + Base.string(wrapped_text, "
", wrapped_result) + else + Base.string(wrapped_text, " ", wrapped_result) + end Base.push!(labels, label) end @@ -110,20 +128,20 @@ function group_labels(df::DataFrame)::DataFrame return grouped_labels end -FLOW_DIAGRAM_TOP_MARGIN::Number = 1.4 +FLOW_DIAGRAM_TOP_MARGIN::Number = 1 FLOW_DIAGRAM_ROW_01::Number = 15.5 -FLOW_DIAGRAM_ROW_02::Number = FLOW_DIAGRAM_ROW_01 - 1 +FLOW_DIAGRAM_ROW_02::Number = FLOW_DIAGRAM_ROW_01 - 0.75 FLOW_DIAGRAM_ROW_03::Number = FLOW_DIAGRAM_ROW_02 - FLOW_DIAGRAM_TOP_MARGIN FLOW_DIAGRAM_ROW_04::Number = FLOW_DIAGRAM_ROW_03 - FLOW_DIAGRAM_TOP_MARGIN FLOW_DIAGRAM_ROW_05::Number = FLOW_DIAGRAM_ROW_04 - FLOW_DIAGRAM_TOP_MARGIN FLOW_DIAGRAM_ROW_06::Number = FLOW_DIAGRAM_ROW_05 - FLOW_DIAGRAM_TOP_MARGIN FLOW_DIAGRAM_ROW_07::Number = FLOW_DIAGRAM_ROW_06 - FLOW_DIAGRAM_TOP_MARGIN -FLOW_DIAGRAM_LEFT_MARGIN::Number = 2.65 +FLOW_DIAGRAM_LEFT_MARGIN::Number = 2.5 FLOW_DIAGRAM_COL_01::Number = 01 -FLOW_DIAGRAM_COL_02::Number = FLOW_DIAGRAM_COL_01 + FLOW_DIAGRAM_LEFT_MARGIN +FLOW_DIAGRAM_COL_02::Number = FLOW_DIAGRAM_COL_01 + 1.25 FLOW_DIAGRAM_COL_03::Number = FLOW_DIAGRAM_COL_02 + FLOW_DIAGRAM_LEFT_MARGIN FLOW_DIAGRAM_COL_04::Number = FLOW_DIAGRAM_COL_03 + FLOW_DIAGRAM_LEFT_MARGIN FLOW_DIAGRAM_COL_05::Number = FLOW_DIAGRAM_COL_04 + FLOW_DIAGRAM_LEFT_MARGIN @@ -234,6 +252,7 @@ $docstring_flow_diagram function flow_diagram( data::DataFrame=flow_diagram_df(); background_color::AbstractString="white", + boxes_color::AbstractString="white", grayboxes::Bool=true, grayboxes_color::AbstractString="#f0f0f0", top_boxes::Bool=true, @@ -250,7 +269,7 @@ function flow_diagram( border_color::AbstractString="black", font::AbstractString="Helvetica", font_color::AbstractString="black", - font_size::Union{AbstractString,Number}=10, + font_size::Union{AbstractString,Number}=8, arrow_head::AbstractString="normal", arrow_size::Union{AbstractString,Number}=1, arrow_color::AbstractString="black", @@ -288,7 +307,7 @@ function flow_diagram( """ for row in eachrow(group_labels(data)) - box_color = "white" + box_color = boxes_color box_border_width = border_width if top_boxes && row.box_num in TOP_BOXES @@ -325,8 +344,8 @@ function flow_diagram( fontcolor="$font_color", fontsize="$font_size", pos="$(pos.x),$(pos.y)!", - width=2 - height=0 + width=$(row.box_num in SIDE_BOXES ? 1 : row.box_num in [2, 3] ? 4.5 : 2), + height=$(row.box_num in [4, 6] ? 1.5 : row.box_num in [5] ? 2 : 0), ]; """ end diff --git a/src/flow_diagram_docstrings.jl b/src/flow_diagram_docstrings.jl index a13ef3e..3bd3878 100644 --- a/src/flow_diagram_docstrings.jl +++ b/src/flow_diagram_docstrings.jl @@ -14,6 +14,7 @@ const docstring_flow_diagram::String = PRISMA.flow_diagram( data::DataFrame=flow_diagram_df(), background_color::AbstractString="white", + boxes_color::AbstractString="white", grayboxes::Bool=true, grayboxes_color::AbstractString="#f0f0f0", top_boxes::Bool=true, @@ -45,6 +46,7 @@ generates the flow diagram figure from the flow diagram dataframe. ## Keyword Arguments - `background_color::String`: The background color of the flow diagram. Default is `white`. +- `boxes_color::String`: The color of the boxes. Default is `white`. - `grayboxes::Bool`: Whether to show gray boxes. Default is `true`. - `grayboxes_color::String`: The color of the gray boxes. Default is `#f0f0f0`. - `top_boxes::Bool`: Whether to show top boxes. Default is `true`.