pub(super) const COLORBAR_MARGIN_PX: f32 = 10.0;
pub(super) const COLORBAR_WIDTH_PX: f32 = 20.0;
macro_rules! impl_series_continuation_methods {
($self_:ident.$finalize:ident()) => {
pub fn line<X, Y>(
$self_,
x_data: &X,
y_data: &Y,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::LineConfig>
where
X: $crate::data::NumericData1D,
Y: $crate::data::NumericData1D,
{
$self_.$finalize().line(x_data, y_data)
}
pub fn line_source<X, Y>(
$self_,
x_data: X,
y_data: Y,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::LineConfig>
where
X: $crate::core::plot::IntoPlotData,
Y: $crate::core::plot::IntoPlotData,
{
$self_.$finalize().line_source(x_data, y_data)
}
pub fn scatter<X, Y>(
$self_,
x_data: &X,
y_data: &Y,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::ScatterConfig>
where
X: $crate::data::NumericData1D,
Y: $crate::data::NumericData1D,
{
$self_.$finalize().scatter(x_data, y_data)
}
pub fn scatter_source<X, Y>(
$self_,
x_data: X,
y_data: Y,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::ScatterConfig>
where
X: $crate::core::plot::IntoPlotData,
Y: $crate::core::plot::IntoPlotData,
{
$self_.$finalize().scatter_source(x_data, y_data)
}
pub fn bar<S, V>(
$self_,
categories: &[S],
values: &V,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::BarConfig>
where
S: ToString,
V: $crate::data::NumericData1D,
{
$self_.$finalize().bar(categories, values)
}
pub fn bar_source<S, V>(
$self_,
categories: &[S],
values: V,
) -> $crate::core::plot::PlotBuilder<$crate::plots::basic::BarConfig>
where
S: ToString,
V: $crate::core::plot::IntoPlotData,
{
$self_.$finalize().bar_source(categories, values)
}
pub fn group<F>($self_, f: F) -> $crate::core::plot::Plot
where
F: FnOnce(
$crate::core::plot::SeriesGroupBuilder,
) -> $crate::core::plot::SeriesGroupBuilder,
{
$self_.$finalize().group(f)
}
pub fn histogram<D: $crate::data::NumericData1D>(
$self_,
data: &D,
config: Option<$crate::plots::HistogramConfig>,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().histogram(data, config)
}
pub fn histogram_source<D: $crate::core::plot::IntoPlotData>(
$self_,
data: D,
config: Option<$crate::plots::HistogramConfig>,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().histogram_source(data, config)
}
pub fn boxplot<D: $crate::data::NumericData1D>(
$self_,
data: &D,
config: Option<$crate::plots::BoxPlotConfig>,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().boxplot(data, config)
}
pub fn boxplot_source<D: $crate::core::plot::IntoPlotData>(
$self_,
data: D,
config: Option<$crate::plots::BoxPlotConfig>,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().boxplot_source(data, config)
}
pub fn heatmap<D>(
$self_,
data: &D,
config: Option<$crate::plots::heatmap::HeatmapConfig>,
) -> $crate::core::plot::PlotSeriesBuilder
where
D: $crate::data::NumericData2D + ?Sized,
{
$self_.$finalize().heatmap(data, config)
}
pub fn kde<T, D: $crate::data::Data1D<T>>(
$self_,
data: &D,
) -> $crate::core::plot::PlotBuilder<$crate::plots::KdeConfig>
where
T: Into<f64> + Copy,
{
$self_.$finalize().kde(data)
}
pub fn ecdf<T, D: $crate::data::Data1D<T>>(
$self_,
data: &D,
) -> $crate::core::plot::PlotBuilder<$crate::plots::EcdfConfig>
where
T: Into<f64> + Copy,
{
$self_.$finalize().ecdf(data)
}
pub fn contour<X, Y, Z>(
$self_,
x: &X,
y: &Y,
z: &Z,
) -> $crate::core::plot::PlotBuilder<$crate::plots::ContourConfig>
where
X: $crate::data::Data1D<f64>,
Y: $crate::data::Data1D<f64>,
Z: $crate::data::Data1D<f64>,
{
$self_.$finalize().contour(x, y, z)
}
pub fn pie<V>(
$self_,
values: &V,
) -> $crate::core::plot::PlotBuilder<$crate::plots::PieConfig>
where
V: $crate::data::Data1D<f64>,
{
$self_.$finalize().pie(values)
}
pub fn radar<S: AsRef<str>>(
$self_,
labels: &[S],
) -> $crate::core::plot::PlotBuilder<$crate::plots::RadarConfig> {
$self_.$finalize().radar(labels)
}
pub fn polar_line<R, T>(
$self_,
r: &R,
theta: &T,
) -> $crate::core::plot::PlotBuilder<$crate::plots::PolarPlotConfig>
where
R: $crate::data::Data1D<f64>,
T: $crate::data::Data1D<f64>,
{
$self_.$finalize().polar_line(r, theta)
}
pub fn violin<T, D: $crate::data::Data1D<T>>(
$self_,
data: &D,
) -> $crate::core::plot::PlotBuilder<$crate::plots::ViolinConfig>
where
T: Into<f64> + Copy,
{
$self_.$finalize().violin(data)
}
pub fn line_streaming(
$self_,
stream: &$crate::data::StreamingXY,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().line_streaming(stream)
}
pub fn scatter_streaming(
$self_,
stream: &$crate::data::StreamingXY,
) -> $crate::core::plot::PlotSeriesBuilder {
$self_.$finalize().scatter_streaming(stream)
}
pub fn error_bars<X, Y, E>(
$self_,
x_data: &X,
y_data: &Y,
y_errors: &E,
) -> $crate::core::plot::PlotSeriesBuilder
where
X: $crate::data::NumericData1D,
Y: $crate::data::NumericData1D,
E: $crate::data::NumericData1D,
{
$self_.$finalize().error_bars(x_data, y_data, y_errors)
}
pub fn error_bars_source<X, Y, E>(
$self_,
x_data: X,
y_data: Y,
y_errors: E,
) -> $crate::core::plot::PlotSeriesBuilder
where
X: $crate::core::plot::IntoPlotData,
Y: $crate::core::plot::IntoPlotData,
E: $crate::core::plot::IntoPlotData,
{
$self_.$finalize().error_bars_source(x_data, y_data, y_errors)
}
pub fn error_bars_xy<X, Y, EX, EY>(
$self_,
x_data: &X,
y_data: &Y,
x_errors: &EX,
y_errors: &EY,
) -> $crate::core::plot::PlotSeriesBuilder
where
X: $crate::data::NumericData1D,
Y: $crate::data::NumericData1D,
EX: $crate::data::NumericData1D,
EY: $crate::data::NumericData1D,
{
$self_.$finalize().error_bars_xy(x_data, y_data, x_errors, y_errors)
}
pub fn error_bars_xy_source<X, Y, EX, EY>(
$self_,
x_data: X,
y_data: Y,
x_errors: EX,
y_errors: EY,
) -> $crate::core::plot::PlotSeriesBuilder
where
X: $crate::core::plot::IntoPlotData,
Y: $crate::core::plot::IntoPlotData,
EX: $crate::core::plot::IntoPlotData,
EY: $crate::core::plot::IntoPlotData,
{
$self_
.$finalize()
.error_bars_xy_source(x_data, y_data, x_errors, y_errors)
}
};
}
mod annotations;
mod builder;
mod config;
mod configuration;
mod construction;
pub mod data;
mod image;
mod interactive_session;
mod layout_manager;
mod mixed_render;
mod parallel_render;
mod prepared;
mod raster_fast_path;
mod render;
mod render_pipeline;
mod series_api;
mod series_builders;
mod series_internal;
mod series_manager;
#[cfg(test)]
#[allow(deprecated)]
mod tests;
mod types;
pub use builder::{IntoPlot, PlotBuilder, PlotInput, SeriesStyle};
pub use config::{BackendType, GridMode, TickDirection, TickSides};
pub use configuration::{PlotConfiguration, TextEngineMode};
pub use data::{IntoPlotData, PlotData, PlotSource, PlotText, ReactiveValue};
pub use image::Image;
pub use interactive_session::{
DirtyDomain, DirtyDomains, FramePacing, FrameStats, HitResult, ImageTarget, InteractiveFrame,
InteractivePlotSession, InteractiveViewportSnapshot, LayerRenderState, PlotInputEvent,
QualityPolicy, RenderTargetKind, SurfaceCapability, SurfaceTarget, ViewportPoint, ViewportRect,
};
pub use layout_manager::LayoutManager;
pub use prepared::{PreparedPlot, ReactiveSubscription};
pub use render_pipeline::RenderPipeline;
pub use series_builders::{PlotSeriesBuilder, SeriesGroupBuilder};
pub use series_manager::SeriesManager;
pub use types::{InsetAnchor, InsetLayout, Plot};
use crate::{
axes::AxisScale,
core::{
Annotation, ArrowStyle, FillStyle, GridStyle, LayoutCalculator, LayoutConfig, Legend,
LegendItem, LegendItemType, LegendPosition, MarginConfig, MeasuredDimensions, PlotConfig,
PlotContent, PlotLayout, PlotStyle, PlottingError, Position, REFERENCE_DPI, RenderScale,
Result, ShapeStyle, TextStyle, pt_to_px,
},
data::{
Data1D, DataShader, NullPolicy, NumericData1D, NumericData2D, StreamingXY,
collect_numeric_data_1d, collect_numeric_data_2d,
},
plots::boxplot::BoxPlotConfig,
plots::error::errorbar::{ErrorBarConfig, ErrorValues},
plots::histogram::HistogramConfig,
plots::traits::PlotRender,
render::skia::{
SkiaRenderer, calculate_plot_area_config, calculate_plot_area_dpi, generate_ticks,
map_data_to_pixels,
},
render::{Color, LineStyle, MarkerStyle, Theme},
};
use std::{
borrow::Cow,
collections::{HashMap, HashSet},
path::Path,
sync::Arc,
};
use self::data::{ReactiveTeardown, SharedReactiveCallback};
pub(crate) use self::types::{
LegendConfig, PendingIngestionError, PlotSeries, ResolvedSeries, SeriesGroupMeta, SeriesType,
TickConfig,
};
#[cfg(feature = "parallel")]
use crate::render::{ParallelRenderer, SeriesRenderData};
#[cfg(feature = "gpu")]
use crate::render::gpu::GpuRenderer;