pub mod breaks;
pub mod colour;
pub mod linetype;
pub mod palettes;
mod scale_type;
pub mod shape;
pub mod transform;
mod types;
pub use crate::format::apply_label_template;
pub use crate::plot::aesthetic::{
is_facet_aesthetic, is_position_aesthetic, is_user_facet_aesthetic,
};
pub use crate::plot::types::CastTargetType;
pub use crate::reader::SqlDialect;
pub use colour::{color_to_hex, gradient, interpolate_colors, is_color_aesthetic, ColorSpace};
pub use linetype::linetype_to_stroke_dash;
pub use scale_type::{
coerce_dtypes, default_oob, dtype_to_cast_target, infer_transform_from_input_range, needs_cast,
Binned, Continuous, Discrete, Identity, InputRange, ScaleDataContext, ScaleType, ScaleTypeKind,
ScaleTypeTrait, TypeFamily, OOB_CENSOR, OOB_KEEP, OOB_SQUISH,
};
pub use shape::shape_to_svg_path;
pub use transform::{Transform, TransformKind, TransformTrait, ALL_TRANSFORM_NAMES};
pub use types::{OutputRange, Scale};
use crate::plot::{ArrayElement, ArrayElementType};
pub fn gets_default_scale(aesthetic: &str) -> bool {
if is_position_aesthetic(aesthetic) {
return true;
}
if is_facet_aesthetic(aesthetic) {
return true;
}
matches!(
aesthetic,
"fill" | "stroke"
| "size" | "linewidth"
| "width" | "height"
| "opacity" | "shape" | "linetype"
)
}
pub fn infer_scale_target_type(scale: &Scale) -> Option<ArrayElementType> {
let scale_type = scale.scale_type.as_ref()?;
match scale_type.scale_type_kind() {
ScaleTypeKind::Discrete | ScaleTypeKind::Ordinal => scale
.input_range
.as_ref()
.and_then(|r| ArrayElement::infer_type(r)),
ScaleTypeKind::Continuous => scale.transform.as_ref().map(|t| t.target_type()),
ScaleTypeKind::Binned => None,
ScaleTypeKind::Identity => None,
}
}