fluent-plots
A declarative and easy-to-use Rust data visualization library for creating static and interactive charts from Polars DataFrames. fluent-plots provides a simple, chainable API for quickly building common plot types.
Features
- Fluent API: Chain methods together to build your chart declaratively.
- Polars
DataFrameIntegration: Designed to work directly with the powerful PolarsDataFrame. - Dual Backends:
- (Default) Static chart rendering using
plotters(drawing logic still in development). - (Optional) Interactive HTML charts powered by
charmingand ECharts.js.
- (Default) Static chart rendering using
- Lightweight: The interactive backend is an optional feature to keep your dependency tree small if you only need static plots.
Installation
Add fluent-plots to your Cargo.toml file.
For interactive charts, enable the interactive feature:
[]
= { = "0.1.0", = ["interactive"] }
= { = "0.41", = ["csv"] } # Needed for the examples
If you only need the static plotting capabilities (once implemented), you can omit the feature flag.
Usage
Here's how to create an interactive bar chart from a Polars DataFrame.
use barchart;
use *;
use fs;
Creating Different Chart Types
You can easily create other chart types by calling linechart() or scatterplot().
use linechart;
use *;
use fs;
// ... create your DataFrame `df` ...
let html_content = linechart
.x
.y
.to_interactive_html?;
write?;
Running with the Example Binary
This repository includes a test application in the plot-tester directory (if you choose to include it) that can be run from the command line to generate charts from a CSV file.
First, create a sample_data.csv file:
category,value
A,10
B,25
C,5
D,42
E,18
Then, run the application:
# Generate a bar chart (default)
# Generate a line chart
# Generate a scatter plot
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.