This shows the options for including data with the HTML
For most charttypes you have some dataset that they should comsume. As part of the constructor you give a symbol that identifies the dataset to be used. Then at the point when you construct a page you input a dict mapping these symbols to an object holding the data.
These symbols can have a period in it in which case you are describing a subfield. For instance you might have an object like that below:
struct ExampleStruct
aa::DataFrame
bb::DataFrame
end
example_struct = ExampleStruct(df1, df2)
Then if you have a chart that wants to use the aa dataset from this object then you can specify it with Symbol("example_struct.aa") and then later on you give the data in the dict as Dict{Symbol,Any}(:example_struct => example_struct).
The point of this system is twofold. For one certain charts may require datasets and so it is easier in this case to have a struct to hold everything together (Currently this is only ExecutionChart but maybe in the future). So if you wanted to put in a pivottable in the same page to show only the fills data you could do that without putting in the data twice. The second reason is that using structs in this way will bunch the data in different subfolders in cases where an external data format is used (:parquet, :json_external or :csv_external as described below).
JSPlots.jl supports multiple data storage formats for embedding data in HTML pages. The format affects file size, loading speed, and browser compatibility.
Best for: Large datasets, multi-page reports, production use
page = JSPlotPage(data_dict, charts, dataformat = :parquet)
Best for: Small datasets, maximum compatibility, debugging
page = JSPlotPage(data_dict, charts, dataformat = :csv_embedded)
Best for: Sharing data files, version control, spreadsheet analysis
page = JSPlotPage(data_dict, charts, dataformat = :csv_external)
Best for: Small datasets, web developers, API-like structure
page = JSPlotPage(data_dict, charts, dataformat = :json_embedded)
Best for: API consumption, web applications, data interchange
page = JSPlotPage(data_dict, charts, dataformat = :json_external)
Key Efficiency Feature: JSPlots.jl automatically detects when the same dataset is used multiple times and only includes it once.
Note that thisData deduplication only works with external formats
Data deduplication only works with external formats - (:parquet, :csv_external, :json_external).
With embedded formats (:csv_embedded, :json_embedded),
data is embedded separately in each HTML page, so there's no deduplication benefit.
When you create a multi-page report with Pages, datasets are identified by their
Symbol key in the data dictionary. The Pages-level dataformat setting
overrides any individual JSPlotPage dataformat settings.
# Both pages use :sales_data
page1 = JSPlotPage(
Dict(:sales_data => df),
[chart1, chart2],
dataformat = :csv_embedded # This is ignored!
)
page2 = JSPlotPage(
Dict(:sales_data => df), # Same Symbol = reuses data!
[chart3, chart4],
dataformat = :json_embedded # This is also ignored!
)
# Pages-level dataformat is what actually gets used
report = Pages(
[intro],
[page1, page2],
dataformat = :parquet # ← This overrides page-level settings!
)
# Result: One parquet file in data/sales_data.parquet shared by both pages
| Feature | :parquet | :csv_embedded | :csv_external | :json_embedded | :json_external |
|---|---|---|---|---|---|
| File Size | Smallest (5-10x smaller) | Medium | Medium | Large (~25% bigger than CSV) | Large (~25% bigger than CSV) |
| Loading Speed | Fast | Moderate | Moderate | Fast (native JSON.parse) | Fast (native JSON.parse) |
| Compatibility | Modern browsers | Universal | Universal | Universal | Universal |
| Deduplication | Yes (in Pages) | No (embedded) | Yes (in Pages) | No (embedded) | Yes (in Pages) |
| Type Preservation | Excellent | Limited (strings) | Limited (strings) | Good | Good |
| Human Readable | No (binary) | Yes (in HTML) | Yes (separate files) | Yes (in HTML) | Yes (separate files) |
| File Structure | Single HTML + data/ | Single HTML | HTML + data/ folder | Single HTML | HTML + data/ folder |
| Best For | Production, large data | Small data, debugging | Spreadsheet analysis | Web developers | API/web apps |
# Set format for entire report (RECOMMENDED)
report = Pages(
[intro],
[page1, page2],
dataformat = :parquet # Overrides any page-level settings
)
# Individual pages (only for single-page JSPlotPage, not Pages)
page1 = JSPlotPage(data_dict, charts, dataformat = :parquet)
create_html(page1, "standalone_page.html")
Note: When using Pages, the Pages-level dataformat
overrides any dataformat settings in individual JSPlotPage objects.
When using external formats (:parquet, :csv_external, :json_external),
JSPlots.jl automatically generates launcher scripts to help with browser security restrictions:
Why launcher scripts? Modern browsers block loading external files (data/, pictures/, etc.)
from file:// URLs for security reasons. The launcher scripts either:
For embedded formats (:csv_embedded, :json_embedded), you can open
the HTML file directly in a browser since all data is embedded - no launcher scripts needed!
This page was created using JSPlots.jl v0.4.1.