Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/kaleido/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ fn main() {
std::fs::create_dir_all("./output").unwrap();
let filename = "./output/inline_image".to_string();

// The image will be saved to format!("output/image.{image_format}") relative to
// the current working directory.
// The image will be saved to format!("output/image.{image_format}")
// relative to the current working directory.
#[allow(deprecated)]
{
plot.write_image(&filename, ImageFormat::EPS, width, height, scale);
Expand Down
4 changes: 2 additions & 2 deletions examples/static_export/src/bin/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.expect("Failed to create StaticExporter");

info!("Exporting multiple plots using a single StaticExporter...");
// Export all plots using the same exporter (new unified naming via extension
// trait)
// Export all plots using the same exporter (new unified naming via
// extension trait)
exporter.write_image(
&plot1,
"./output/plot1_new_api",
Expand Down
1 change: 0 additions & 1 deletion plotly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ authors = [
]
license = "MIT"
readme = "../README.md"
homepage = "https://github.com/plotly/plotly.rs"
documentation = "https://docs.rs/plotly"
repository = "https://github.com/plotly/plotly.rs"
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions plotly/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,8 @@ mod tests {

#[test]
fn serialize_direction() {
// TODO: I think `Direction` would be better as a struct, with `fillcolor` and
// `line` attributes
// TODO: I think `Direction` would be better as a struct, with
// `fillcolor` and `line` attributes
let inc = Direction::Increasing { line: Line::new() };
let expected = json!({"line": {}});
assert_eq!(to_value(inc).unwrap(), expected);
Expand Down
4 changes: 2 additions & 2 deletions plotly/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ pub enum PlotGLPixelRatio {
#[serde(rename_all = "camelCase")]
pub struct Configuration {
// reference is here: https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js
// missing: edits, show_sources, mode_bar_buttons, set_background, logging, notify_on_logging,
// global_transforms, mode_bar_buttons_to_add and locales
// missing: edits, show_sources, mode_bar_buttons, set_background, logging,
// notify_on_logging, global_transforms, mode_bar_buttons_to_add and locales
typeset_math: Option<bool>,
autosizable: Option<bool>,
scroll_zoom: Option<bool>,
Expand Down
4 changes: 2 additions & 2 deletions plotly/src/layout/polar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ mod tests {
use crate::Layout;

// The focus of the test is serialization, so we test all options for
// [`LayoutPolar`], even though some of those options would normally be mutually
// exclusive.
// [`LayoutPolar`], even though some of those options would normally be
// mutually exclusive.
#[test]
fn serialize_layout_polar() {
let ticks = PolarAxisTicks::new()
Expand Down
6 changes: 4 additions & 2 deletions plotly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//! The `kaleido` and `kaleido_download` features are deprecated since version
//! 0.13.0 and will be removed in version 0.15.0. Please migrate to the
//! `plotly_static` and `static_export_*` features instead.
#![recursion_limit = "256"] // lets us use a large serde_json::json! macro for testing crate::layout::Axis
#![recursion_limit = "256"] // lets us use a large serde_json::json! macro for
// testing crate::layout::Axis
extern crate askama;
extern crate rand;
extern crate serde;
Expand Down Expand Up @@ -58,7 +59,8 @@ pub use common::color;
pub use configuration::Configuration;
pub use layout::Layout;
pub use plot::{Plot, Trace, Traces};
// Also provide easy access to modules which contain additional trace-specific types
// Also provide easy access to modules which contain additional trace-specific
// types
pub use traces::{
box_plot, choropleth, choropleth_map, contour, density_map, funnel, heat_map, histogram,
histogram2d, icicle, image, indicator, mesh3d, parcats, sankey, scatter, scatter3d,
Expand Down
17 changes: 10 additions & 7 deletions plotly/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ impl Plot {
file.flush().unwrap();
}

// Hand off the job of opening the browser to an OS-specific implementation.
// Hand off the job of opening the browser to an OS-specific
// implementation.
Plot::show_with_default_app(temp_path);
}

Expand All @@ -311,7 +312,8 @@ impl Plot {
pub fn show_html<P: AsRef<Path> + std::clone::Clone>(&self, filename: P) {
let path = filename.as_ref().to_str().unwrap();
self.write_html(filename.clone());
// Hand off the job of opening the browser to an OS-specific implementation.
// Hand off the job of opening the browser to an OS-specific
// implementation.
Plot::show_with_default_app(path);
}

Expand Down Expand Up @@ -342,7 +344,8 @@ impl Plot {
file.flush().unwrap();
}

// Hand off the job of opening the browser to an OS-specific implementation.
// Hand off the job of opening the browser to an OS-specific
// implementation.
Plot::show_with_default_app(temp_path);
}

Expand Down Expand Up @@ -739,8 +742,8 @@ impl Plot {
/// This is used when the `plotly_embed_js` feature is enabled, providing
/// self-contained HTML files that don't require external CDN resources.
pub fn offline_js_sources() -> String {
// Note that since 'tex-mml-chtml' conflicts with 'tex-svg' when generating
// Latex Titles we no longer include it.
// Note that since 'tex-mml-chtml' conflicts with 'tex-svg' when
// generating Latex Titles we no longer include it.
let local_tex_svg_js = include_str!("../resource/tex-svg-3.2.2.js");
let local_plotly_js = include_str!("../resource/plotly.min.js");

Expand All @@ -764,8 +767,8 @@ impl Plot {
/// disabled, providing smaller HTML files that rely on external
/// resources.
pub fn online_cdn_js() -> String {
// Note that since 'tex-mml-chtml' conflicts with 'tex-svg' when generating
// Latex Titles we no longer include it.
// Note that since 'tex-mml-chtml' conflicts with 'tex-svg' when
// generating Latex Titles we no longer include it.
r##"<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
<script src="https://cdn.plot.ly/plotly-3.7.0.min.js"></script>
"##
Expand Down
8 changes: 5 additions & 3 deletions plotly/src/traces/violin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use plotly_derive::FieldSetter;
use serde::{Serialize, Serializer};

// Re-use the box plot's quartile method, whose values (linear/exclusive/inclusive)
// are identical to the violin trace's `quartilemethod` attribute.
// Re-use the box plot's quartile method, whose values
// (linear/exclusive/inclusive) are identical to the violin trace's
// `quartilemethod` attribute.
pub use super::box_plot::QuartileMethod;
use crate::{
color::Color,
Expand Down Expand Up @@ -324,7 +325,8 @@ mod tests {
let numeric = Violin::new(vec![1, 2, 3]).span(vec![0., 10.]);
assert_eq!(to_value(numeric).unwrap()["span"], json!([0.0, 10.0]));

// Date/string span for date-valued axes (plotly.js types `span` as `any`).
// Date/string span for date-valued axes (plotly.js types `span` as
// `any`).
let dated = Violin::new(vec![1, 2, 3])
.span_mode(SpanMode::Manual)
.span(vec!["2020-01-01", "2020-12-31"]);
Expand Down
1 change: 0 additions & 1 deletion plotly_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.14.1"
description = "Internal proc macro crate for Plotly-rs."
authors = ["Ioannis Giagkiozis <i.giagkiozis@gmail.com>"]
license = "MIT"
homepage = "https://github.com/plotly/plotly.rs"
documentation = "https://docs.rs/plotly"
repository = "https://github.com/plotly/plotly.rs"
edition = "2021"
Expand Down
7 changes: 4 additions & 3 deletions plotly_derive/src/field_setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ impl FieldReceiver {
_ => quote![],
};

// Optional matrix setter for Dim<_> when #[field_setter(with_matrix)] is
// present
// Optional matrix setter for Dim<_> when #[field_setter(with_matrix)]
// is present
let matrix_setter = if self.with_matrix {
let matrix_ident = Ident::new(
&format!("{field_ident}_matrix"),
Expand Down Expand Up @@ -541,7 +541,8 @@ impl FieldReceiver {
#return_stmt
}
},
// Generic matrix for other inner types that are already concrete (f64, enums, etc.)
// Generic matrix for other inner types that are already
// concrete (f64, enums, etc.)
FieldType::OptionDimOther(inner_ty) => quote! {
#field_docs
pub fn #matrix_ident(mut self, value: Vec<Vec<#inner_ty>>) -> #return_ty {
Expand Down
3 changes: 2 additions & 1 deletion plotly_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ pub fn layout_structs(_attr: TokenStream, item: TokenStream) -> TokenStream {
#vis struct #template_struct_name #fields
};

// Generate Layout (with template field and #[field_setter(kind = "layout")])
// Generate Layout (with template field and #[field_setter(kind =
// "layout")])
let layout_struct_name = format_ident!("Layout");
let mut layout_fields = fields.clone();
// Add the template field
Expand Down
1 change: 0 additions & 1 deletion plotly_kaleido/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ authors = [
license = "MIT"
readme = "README.md"
workspace = ".."
homepage = "https://github.com/plotly/plotly.rs"
documentation = "https://docs.rs/plotly_kaleido"
repository = "https://github.com/plotly/plotly.rs"
edition = "2021"
Expand Down
16 changes: 8 additions & 8 deletions plotly_kaleido/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ struct PlotData<'a> {
width: usize,
height: usize,
scale: f64,
// TODO: it would be great if this could be a plotly::Plot, but with the current workspace set
// up, that would be a cyclic dependency.
// TODO: it would be great if this could be a plotly::Plot, but with the
// current workspace set up, that would be a cyclic dependency.
data: &'a Value,
}

Expand Down Expand Up @@ -259,8 +259,8 @@ impl Kaleido {
let p = self.cmd_path.to_str().unwrap();
let format_str = format.to_string();

// Removed flag 'disable-gpu' as it causes issues on MacOS and other platforms
// see Kaleido issue #323
// Removed flag 'disable-gpu' as it causes issues on MacOS and other
// platforms see Kaleido issue #323
let cmd_args = vec![
"plotly",
"--allow-file-access-from-files",
Expand Down Expand Up @@ -303,10 +303,10 @@ impl Kaleido {
let res = KaleidoResult::from(line.as_str());
if let Some(image_data) = res.result {
// TODO: this should be refactored
// The assumption is that KaleidoResult contains a single image.
// We should end the loop on the first valid one.
// If that is not the case, prior implementation would have returned the last
// valid image
// The assumption is that KaleidoResult contains a single
// image. We should end the loop on the first valid one.
// If that is not the case, prior implementation would have
// returned the last valid image
return Ok(image_data);
}
}
Expand Down
3 changes: 1 addition & 2 deletions plotly_static/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ description = "Export Plotly graphs to static images using WebDriver"
authors = ["Andrei Gherghescu andrei-ng@protonmail.com"]
license = "MIT"
workspace = ".."
homepage = "https://github.com/plotly/plotly.rs"
repository = "https://github.com/plotly/plotly.rs"
edition = "2021"
keywords = ["plotly", "static", "image", "export", "webdriver"]
Expand Down Expand Up @@ -40,7 +39,7 @@ clap = { version = "4.0", features = ["derive"] }
[build-dependencies]
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"
dirs = "6.0"
dirs = "7.0"
zip = "8.0"
webdriver-downloader = "0.17"

Expand Down
25 changes: 14 additions & 11 deletions plotly_static/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,14 +1060,15 @@ impl AsyncStaticExporter {
new_client
};

// For offline mode, write HTML to file to avoid data URI size limits since JS
// libraries are embedded in the file
// For offline mode, write HTML to file to avoid data URI size limits
// since JS libraries are embedded in the file
let url = if self.offline_mode {
let temp_file = template::to_file(html_content)
.with_context(|| "Failed to create temporary HTML file")?;
format!("file://{}", temp_file.to_string_lossy())
} else {
// For online mode, use data URI (smaller size since JS is loaded from CDN)
// For online mode, use data URI (smaller size since JS is loaded
// from CDN)
format!("data:text/html,{}", encode(html_content))
};

Expand Down Expand Up @@ -1143,7 +1144,8 @@ impl AsyncStaticExporter {
}
#[cfg(any(feature = "chromedriver", feature = "geckodriver"))]
{
// Define browser capabilities (copied to avoid reordering existing code)
// Define browser capabilities (copied to avoid reordering existing
// code)
let mut caps = JsonMap::new();
let mut browser_opts = JsonMap::new();
let browser_args = self.webdriver_browser_caps.clone();
Expand Down Expand Up @@ -1373,8 +1375,8 @@ mod tests {
PORT_COUNTER.fetch_add(1, Ordering::SeqCst)
}

// In CI which may run on slow machines, we run a different strategy to generate
// the unique port.
// In CI which may run on slow machines, we run a different strategy to
// generate the unique port.
#[cfg(feature = "debug")]
fn get_unique_port() -> u32 {
static PORT_COUNTER: AtomicU32 = AtomicU32::new(4844);
Expand Down Expand Up @@ -1669,8 +1671,8 @@ mod tests {
assert!(std::fs::remove_file(dst1.as_path()).is_ok());
exporter1.close();

// Create second exporter on the same port - this should connect to existing
// WebDriver process (but create a new session)
// Create second exporter on the same port - this should connect to
// existing WebDriver process (but create a new session)
let mut exporter2 = StaticExporterBuilder::default()
.spawn_webdriver(true)
.webdriver_port(test_port)
Expand All @@ -1687,15 +1689,16 @@ mod tests {
assert!(std::fs::remove_file(dst2.as_path()).is_ok());
exporter2.close();

// Create third exporter on the same port - should also connect to existing
// WebDriver process
// Create third exporter on the same port - should also connect to
// existing WebDriver process
let mut exporter3 = StaticExporterBuilder::default()
.spawn_webdriver(true)
.webdriver_port(test_port)
.build()
.unwrap();

// Export third image using another new session on the same WebDriver process
// Export third image using another new session on the same WebDriver
// process
let dst3 = PathBuf::from("process_reuse_3.png");
exporter3
.write_fig(dst3.as_path(), &test_plot, ImageFormat::PNG, 800, 600, 1.0)
Expand Down
3 changes: 2 additions & 1 deletion plotly_static/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ pub(crate) fn to_file(data: &str) -> Result<PathBuf> {

fn offline_js_sources() -> String {
// tex-mml-chtml conflicts with tex-svg when generating Latex Titles
// let local_tex_mml_js = include_str!("../resource/tex-mml-chtml-3.2.0.js");
// let local_tex_mml_js =
// include_str!("../resource/tex-mml-chtml-3.2.0.js");
let local_plotly_js = include_str!("../resource/plotly.min.js");
let local_tex_svg_js = include_str!("../resource/tex-svg-3.2.2.js");
let local_html2pdf_js = include_str!("../resource/html2pdf.bundle.min.js");
Expand Down
3 changes: 2 additions & 1 deletion plotly_static/src/webdriver/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ impl WebDriver {
}

fn spawn_process(&self, driver_path: &Option<PathBuf>, port: u32) -> Result<Child> {
let driver_path = driver_path.as_ref().unwrap(); // Safe unwrap since we validated above
let driver_path = driver_path.as_ref().unwrap(); // Safe unwrap since we
// validated above

let mut command = Self::create_command(driver_path, port);
Self::log_command(&command);
Expand Down
Loading