aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2024-02-05 09:40:40 +0100
committerJeff Vander Stoep <jeffv@google.com>2024-02-05 09:40:40 +0100
commit38dcba571da88bb8b9ebc8aa9f1409377c32857a (patch)
treea1745a49ce071c422202838e39bcf72cceabe9ed
parentb001901f7caa2989d4eb99741581387041e3fd89 (diff)
downloadplotters-38dcba571da88bb8b9ebc8aa9f1409377c32857a.tar.gz
Upgrade plotters to 0.3.5
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/rust/crates/plotters For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Test: TreeHugger Change-Id: Idc7a8efb584d0ebb87461ade1b89227a3c5bcaa7
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp2
-rw-r--r--Cargo.lock.saved1262
-rw-r--r--Cargo.toml31
-rw-r--r--Cargo.toml.orig29
-rw-r--r--LICENSE22
-rw-r--r--METADATA25
-rw-r--r--README.md602
-rw-r--r--examples/3d-plot2.rs4
-rw-r--r--examples/colormaps.rs69
-rw-r--r--examples/mandelbrot.rs2
-rw-r--r--src/chart/context/cartesian2d/draw_impl.rs5
-rw-r--r--src/chart/dual_coord.rs2
-rw-r--r--src/chart/series.rs4
-rw-r--r--src/coord/ranged1d/types/datetime.rs128
-rw-r--r--src/drawing/area.rs16
-rw-r--r--src/element/pie.rs14
-rw-r--r--src/evcxr.rs2
-rw-r--r--src/lib.rs168
-rw-r--r--src/series/line_series.rs3
-rw-r--r--src/style/colors/colormaps.rs311
-rw-r--r--src/style/colors/mod.rs8
-rw-r--r--src/style/font/ab_glyph.rs160
-rw-r--r--src/style/font/mod.rs26
-rw-r--r--src/style/font/ttf.rs4
-rw-r--r--src/style/mod.rs3
26 files changed, 873 insertions, 2031 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 9101386..72a0af3 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "b1dc7a98acbafb5a3c4980e73f18c4fe74ed84a2"
+ "sha1": "8aeeba24564f3395aa4c759afb404ac854d4d8dd"
},
"path_in_vcs": "plotters"
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 74ea240..25fb873 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,7 +23,7 @@ rust_library {
host_supported: true,
crate_name: "plotters",
cargo_env_compat: true,
- cargo_pkg_version: "0.3.4",
+ cargo_pkg_version: "0.3.5",
srcs: ["src/lib.rs"],
edition: "2018",
features: [
diff --git a/Cargo.lock.saved b/Cargo.lock.saved
deleted file mode 100644
index 66be7f6..0000000
--- a/Cargo.lock.saved
+++ /dev/null
@@ -1,1262 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 3
-
-[[package]]
-name = "adler"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
-
-[[package]]
-name = "android_system_properties"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi",
- "libc",
- "winapi",
-]
-
-[[package]]
-name = "autocfg"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
-
-[[package]]
-name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
-[[package]]
-name = "bstr"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
-dependencies = [
- "lazy_static",
- "memchr",
- "regex-automata",
- "serde",
-]
-
-[[package]]
-name = "bumpalo"
-version = "3.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
-
-[[package]]
-name = "bytemuck"
-version = "1.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da"
-
-[[package]]
-name = "byteorder"
-version = "1.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
-
-[[package]]
-name = "cast"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
-
-[[package]]
-name = "cc"
-version = "1.0.73"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
-
-[[package]]
-name = "cfg-if"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
-
-[[package]]
-name = "chrono"
-version = "0.4.22"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
-dependencies = [
- "iana-time-zone",
- "js-sys",
- "num-integer",
- "num-traits",
- "time",
- "wasm-bindgen",
- "winapi",
-]
-
-[[package]]
-name = "clap"
-version = "2.34.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
-dependencies = [
- "bitflags",
- "textwrap",
- "unicode-width",
-]
-
-[[package]]
-name = "cmake"
-version = "0.1.48"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a"
-dependencies = [
- "cc",
-]
-
-[[package]]
-name = "color_quant"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
-
-[[package]]
-name = "console_error_panic_hook"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
-dependencies = [
- "cfg-if",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "const-cstr"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6"
-
-[[package]]
-name = "core-foundation"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
-dependencies = [
- "core-foundation-sys",
- "libc",
-]
-
-[[package]]
-name = "core-foundation-sys"
-version = "0.8.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
-
-[[package]]
-name = "core-graphics"
-version = "0.22.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
-dependencies = [
- "bitflags",
- "core-foundation",
- "core-graphics-types",
- "foreign-types",
- "libc",
-]
-
-[[package]]
-name = "core-graphics-types"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
-dependencies = [
- "bitflags",
- "core-foundation",
- "foreign-types",
- "libc",
-]
-
-[[package]]
-name = "core-text"
-version = "19.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"
-dependencies = [
- "core-foundation",
- "core-graphics",
- "foreign-types",
- "libc",
-]
-
-[[package]]
-name = "crc32fast"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
-dependencies = [
- "cfg-if",
-]
-
-[[package]]
-name = "criterion"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b01d6de93b2b6c65e17c634a26653a29d107b3c98c607c765bf38d041531cd8f"
-dependencies = [
- "atty",
- "cast",
- "clap",
- "criterion-plot",
- "csv",
- "itertools",
- "lazy_static",
- "num-traits",
- "oorandom",
- "plotters 0.3.3",
- "rayon",
- "regex",
- "serde",
- "serde_cbor",
- "serde_derive",
- "serde_json",
- "tinytemplate",
- "walkdir",
-]
-
-[[package]]
-name = "criterion-plot"
-version = "0.4.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876"
-dependencies = [
- "cast",
- "itertools",
-]
-
-[[package]]
-name = "crossbeam-channel"
-version = "0.5.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
-dependencies = [
- "cfg-if",
- "crossbeam-utils",
-]
-
-[[package]]
-name = "crossbeam-deque"
-version = "0.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
-dependencies = [
- "cfg-if",
- "crossbeam-epoch",
- "crossbeam-utils",
-]
-
-[[package]]
-name = "crossbeam-epoch"
-version = "0.9.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
-dependencies = [
- "autocfg",
- "cfg-if",
- "crossbeam-utils",
- "memoffset",
- "once_cell",
- "scopeguard",
-]
-
-[[package]]
-name = "crossbeam-utils"
-version = "0.8.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
-dependencies = [
- "cfg-if",
- "once_cell",
-]
-
-[[package]]
-name = "csv"
-version = "1.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
-dependencies = [
- "bstr",
- "csv-core",
- "itoa 0.4.8",
- "ryu",
- "serde",
-]
-
-[[package]]
-name = "csv-core"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90"
-dependencies = [
- "memchr",
-]
-
-[[package]]
-name = "dirs-next"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
-dependencies = [
- "cfg-if",
- "dirs-sys-next",
-]
-
-[[package]]
-name = "dirs-sys-next"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
-dependencies = [
- "libc",
- "redox_users",
- "winapi",
-]
-
-[[package]]
-name = "dlib"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794"
-dependencies = [
- "libloading",
-]
-
-[[package]]
-name = "dwrote"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b"
-dependencies = [
- "lazy_static",
- "libc",
- "winapi",
- "wio",
-]
-
-[[package]]
-name = "either"
-version = "1.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
-
-[[package]]
-name = "flate2"
-version = "1.0.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
-dependencies = [
- "crc32fast",
- "miniz_oxide",
-]
-
-[[package]]
-name = "float-ord"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7bad48618fdb549078c333a7a8528acb57af271d0433bdecd523eb620628364e"
-
-[[package]]
-name = "font-kit"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21fe28504d371085fae9ac7a3450f0b289ab71e07c8e57baa3fb68b9e57d6ce5"
-dependencies = [
- "bitflags",
- "byteorder",
- "core-foundation",
- "core-graphics",
- "core-text",
- "dirs-next",
- "dwrote",
- "float-ord",
- "freetype",
- "lazy_static",
- "libc",
- "log",
- "pathfinder_geometry",
- "pathfinder_simd",
- "walkdir",
- "winapi",
- "yeslogic-fontconfig-sys",
-]
-
-[[package]]
-name = "foreign-types"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
-dependencies = [
- "foreign-types-shared",
-]
-
-[[package]]
-name = "foreign-types-shared"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
-
-[[package]]
-name = "freetype"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bee38378a9e3db1cc693b4f88d166ae375338a0ff75cb8263e1c601d51f35dc6"
-dependencies = [
- "freetype-sys",
- "libc",
-]
-
-[[package]]
-name = "freetype-sys"
-version = "0.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a"
-dependencies = [
- "cmake",
- "libc",
- "pkg-config",
-]
-
-[[package]]
-name = "getrandom"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
-dependencies = [
- "cfg-if",
- "libc",
- "wasi 0.11.0+wasi-snapshot-preview1",
-]
-
-[[package]]
-name = "gif"
-version = "0.11.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06"
-dependencies = [
- "color_quant",
- "weezl",
-]
-
-[[package]]
-name = "half"
-version = "1.8.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
-
-[[package]]
-name = "hermit-abi"
-version = "0.1.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "iana-time-zone"
-version = "0.1.47"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c495f162af0bf17656d0014a0eded5f3cd2f365fdd204548c2869db89359dc7"
-dependencies = [
- "android_system_properties",
- "core-foundation-sys",
- "js-sys",
- "once_cell",
- "wasm-bindgen",
- "winapi",
-]
-
-[[package]]
-name = "image"
-version = "0.24.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
-dependencies = [
- "bytemuck",
- "byteorder",
- "color_quant",
- "jpeg-decoder",
- "num-rational",
- "num-traits",
- "png",
-]
-
-[[package]]
-name = "itertools"
-version = "0.10.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
-dependencies = [
- "either",
-]
-
-[[package]]
-name = "itoa"
-version = "0.4.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
-
-[[package]]
-name = "itoa"
-version = "1.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
-
-[[package]]
-name = "jpeg-decoder"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b"
-
-[[package]]
-name = "js-sys"
-version = "0.3.59"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
-dependencies = [
- "wasm-bindgen",
-]
-
-[[package]]
-name = "lazy_static"
-version = "1.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-
-[[package]]
-name = "libc"
-version = "0.2.132"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
-
-[[package]]
-name = "libloading"
-version = "0.7.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"
-dependencies = [
- "cfg-if",
- "winapi",
-]
-
-[[package]]
-name = "libm"
-version = "0.2.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565"
-
-[[package]]
-name = "log"
-version = "0.4.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
-dependencies = [
- "cfg-if",
-]
-
-[[package]]
-name = "memchr"
-version = "2.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
-
-[[package]]
-name = "memoffset"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
-dependencies = [
- "autocfg",
-]
-
-[[package]]
-name = "miniz_oxide"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
-dependencies = [
- "adler",
-]
-
-[[package]]
-name = "num-integer"
-version = "0.1.45"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
-dependencies = [
- "autocfg",
- "num-traits",
-]
-
-[[package]]
-name = "num-rational"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
-dependencies = [
- "autocfg",
- "num-integer",
- "num-traits",
-]
-
-[[package]]
-name = "num-traits"
-version = "0.2.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
-dependencies = [
- "autocfg",
- "libm",
-]
-
-[[package]]
-name = "num_cpus"
-version = "1.13.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
-dependencies = [
- "hermit-abi",
- "libc",
-]
-
-[[package]]
-name = "once_cell"
-version = "1.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0"
-
-[[package]]
-name = "oorandom"
-version = "11.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
-
-[[package]]
-name = "pathfinder_geometry"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b7b7e7b4ea703700ce73ebf128e1450eb69c3a8329199ffbfb9b2a0418e5ad3"
-dependencies = [
- "log",
- "pathfinder_simd",
-]
-
-[[package]]
-name = "pathfinder_simd"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "39fe46acc5503595e5949c17b818714d26fdf9b4920eacf3b2947f0199f4a6ff"
-dependencies = [
- "rustc_version",
-]
-
-[[package]]
-name = "pest"
-version = "2.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b0560d531d1febc25a3c9398a62a71256c0178f2e3443baedd9ad4bb8c9deb4"
-dependencies = [
- "thiserror",
- "ucd-trie",
-]
-
-[[package]]
-name = "pkg-config"
-version = "0.3.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
-
-[[package]]
-name = "plotters"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "716b4eeb6c4a1d3ecc956f75b43ec2e8e8ba80026413e70a3f41fd3313d3492b"
-dependencies = [
- "num-traits",
- "plotters-backend",
- "plotters-svg",
- "wasm-bindgen",
- "web-sys",
-]
-
-[[package]]
-name = "plotters"
-version = "0.3.4"
-dependencies = [
- "chrono",
- "criterion",
- "font-kit",
- "image",
- "itertools",
- "lazy_static",
- "num-traits",
- "pathfinder_geometry",
- "plotters-backend",
- "plotters-bitmap",
- "plotters-svg",
- "rand",
- "rand_distr",
- "rand_xorshift",
- "rayon",
- "serde",
- "serde_derive",
- "serde_json",
- "ttf-parser",
- "wasm-bindgen",
- "wasm-bindgen-test",
- "web-sys",
-]
-
-[[package]]
-name = "plotters-backend"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
-
-[[package]]
-name = "plotters-bitmap"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c4a1f21490a6cf4a84c272ad20bd7844ed99a3178187a4c5ab7f2051295beef"
-dependencies = [
- "gif",
- "image",
- "plotters-backend",
-]
-
-[[package]]
-name = "plotters-svg"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f"
-dependencies = [
- "image",
- "plotters-backend",
-]
-
-[[package]]
-name = "png"
-version = "0.17.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c"
-dependencies = [
- "bitflags",
- "crc32fast",
- "flate2",
- "miniz_oxide",
-]
-
-[[package]]
-name = "ppv-lite86"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
-
-[[package]]
-name = "proc-macro2"
-version = "1.0.43"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
-dependencies = [
- "unicode-ident",
-]
-
-[[package]]
-name = "quote"
-version = "1.0.21"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
-dependencies = [
- "proc-macro2",
-]
-
-[[package]]
-name = "rand"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
-dependencies = [
- "libc",
- "rand_chacha",
- "rand_core",
-]
-
-[[package]]
-name = "rand_chacha"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
-dependencies = [
- "ppv-lite86",
- "rand_core",
-]
-
-[[package]]
-name = "rand_core"
-version = "0.6.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
-dependencies = [
- "getrandom",
-]
-
-[[package]]
-name = "rand_distr"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31"
-dependencies = [
- "num-traits",
- "rand",
-]
-
-[[package]]
-name = "rand_xorshift"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
-dependencies = [
- "rand_core",
-]
-
-[[package]]
-name = "rayon"
-version = "1.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
-dependencies = [
- "autocfg",
- "crossbeam-deque",
- "either",
- "rayon-core",
-]
-
-[[package]]
-name = "rayon-core"
-version = "1.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f"
-dependencies = [
- "crossbeam-channel",
- "crossbeam-deque",
- "crossbeam-utils",
- "num_cpus",
-]
-
-[[package]]
-name = "redox_syscall"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
-dependencies = [
- "bitflags",
-]
-
-[[package]]
-name = "redox_users"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
-dependencies = [
- "getrandom",
- "redox_syscall",
- "thiserror",
-]
-
-[[package]]
-name = "regex"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
-dependencies = [
- "regex-syntax",
-]
-
-[[package]]
-name = "regex-automata"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
-
-[[package]]
-name = "regex-syntax"
-version = "0.6.27"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
-
-[[package]]
-name = "rustc_version"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
-dependencies = [
- "semver",
-]
-
-[[package]]
-name = "ryu"
-version = "1.0.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
-
-[[package]]
-name = "same-file"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
-dependencies = [
- "winapi-util",
-]
-
-[[package]]
-name = "scoped-tls"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
-
-[[package]]
-name = "scopeguard"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
-
-[[package]]
-name = "semver"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
-dependencies = [
- "semver-parser",
-]
-
-[[package]]
-name = "semver-parser"
-version = "0.10.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
-dependencies = [
- "pest",
-]
-
-[[package]]
-name = "serde"
-version = "1.0.144"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
-
-[[package]]
-name = "serde_cbor"
-version = "0.11.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
-dependencies = [
- "half",
- "serde",
-]
-
-[[package]]
-name = "serde_derive"
-version = "1.0.144"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "serde_json"
-version = "1.0.85"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
-dependencies = [
- "itoa 1.0.3",
- "ryu",
- "serde",
-]
-
-[[package]]
-name = "syn"
-version = "1.0.99"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
-dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
-]
-
-[[package]]
-name = "textwrap"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
-dependencies = [
- "unicode-width",
-]
-
-[[package]]
-name = "thiserror"
-version = "1.0.34"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252"
-dependencies = [
- "thiserror-impl",
-]
-
-[[package]]
-name = "thiserror-impl"
-version = "1.0.34"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "time"
-version = "0.1.44"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
-dependencies = [
- "libc",
- "wasi 0.10.0+wasi-snapshot-preview1",
- "winapi",
-]
-
-[[package]]
-name = "tinytemplate"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
-dependencies = [
- "serde",
- "serde_json",
-]
-
-[[package]]
-name = "ttf-parser"
-version = "0.15.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd"
-
-[[package]]
-name = "ucd-trie"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
-
-[[package]]
-name = "unicode-ident"
-version = "1.0.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
-
-[[package]]
-name = "unicode-width"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
-
-[[package]]
-name = "walkdir"
-version = "2.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
-dependencies = [
- "same-file",
- "winapi",
- "winapi-util",
-]
-
-[[package]]
-name = "wasi"
-version = "0.10.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
-
-[[package]]
-name = "wasi"
-version = "0.11.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
-
-[[package]]
-name = "wasm-bindgen"
-version = "0.2.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
-dependencies = [
- "cfg-if",
- "wasm-bindgen-macro",
-]
-
-[[package]]
-name = "wasm-bindgen-backend"
-version = "0.2.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
-dependencies = [
- "bumpalo",
- "log",
- "once_cell",
- "proc-macro2",
- "quote",
- "syn",
- "wasm-bindgen-shared",
-]
-
-[[package]]
-name = "wasm-bindgen-futures"
-version = "0.4.32"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad"
-dependencies = [
- "cfg-if",
- "js-sys",
- "wasm-bindgen",
- "web-sys",
-]
-
-[[package]]
-name = "wasm-bindgen-macro"
-version = "0.2.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
-dependencies = [
- "quote",
- "wasm-bindgen-macro-support",
-]
-
-[[package]]
-name = "wasm-bindgen-macro-support"
-version = "0.2.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "wasm-bindgen-backend",
- "wasm-bindgen-shared",
-]
-
-[[package]]
-name = "wasm-bindgen-shared"
-version = "0.2.82"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
-
-[[package]]
-name = "wasm-bindgen-test"
-version = "0.3.32"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "513df541345bb9fcc07417775f3d51bbb677daf307d8035c0afafd87dc2e6599"
-dependencies = [
- "console_error_panic_hook",
- "js-sys",
- "scoped-tls",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "wasm-bindgen-test-macro",
-]
-
-[[package]]
-name = "wasm-bindgen-test-macro"
-version = "0.3.32"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6150d36a03e90a3cf6c12650be10626a9902d70c5270fd47d7a47e5389a10d56"
-dependencies = [
- "proc-macro2",
- "quote",
-]
-
-[[package]]
-name = "web-sys"
-version = "0.3.59"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
-dependencies = [
- "js-sys",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "weezl"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
-
-[[package]]
-name = "winapi"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
-dependencies = [
- "winapi-i686-pc-windows-gnu",
- "winapi-x86_64-pc-windows-gnu",
-]
-
-[[package]]
-name = "winapi-i686-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-
-[[package]]
-name = "winapi-util"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
-dependencies = [
- "winapi",
-]
-
-[[package]]
-name = "winapi-x86_64-pc-windows-gnu"
-version = "0.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
-[[package]]
-name = "wio"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
-dependencies = [
- "winapi",
-]
-
-[[package]]
-name = "yeslogic-fontconfig-sys"
-version = "3.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2bbd69036d397ebbff671b1b8e4d918610c181c5a16073b96f984a38d08c386"
-dependencies = [
- "const-cstr",
- "dlib",
- "once_cell",
- "pkg-config",
-]
diff --git a/Cargo.toml b/Cargo.toml
index ef249f6..61b811e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "plotters"
-version = "0.3.4"
+version = "0.3.5"
authors = ["Hao Hou <haohou302@gmail.com>"]
exclude = [
"doc-template",
@@ -47,19 +47,19 @@ optional = true
version = "0.2.14"
[dependencies.plotters-backend]
-version = "0.3"
+version = "0.3.5"
[dependencies.plotters-bitmap]
-version = "0.3"
+version = "0.3.3"
optional = true
default_features = false
[dependencies.plotters-svg]
-version = "^0.3"
+version = "0.3.5"
optional = true
[dev-dependencies.criterion]
-version = "0.3.6"
+version = "0.4.0"
[dev-dependencies.itertools]
version = "0.10.0"
@@ -77,6 +77,10 @@ version = "1.0.140"
version = "1.0.82"
[features]
+ab_glyph = [
+ "dep:ab_glyph",
+ "once_cell",
+]
all_elements = [
"errorbar",
"candlestick",
@@ -90,14 +94,12 @@ all_series = [
"surface_series",
]
area_series = []
-bitmap_backend = [
- "plotters-bitmap",
- "ttf",
-]
+bitmap_backend = ["plotters-bitmap"]
bitmap_encoder = ["plotters-bitmap/image_encoder"]
bitmap_gif = ["plotters-bitmap/gif_backend"]
boxplot = []
candlestick = []
+colormaps = []
datetime = ["chrono"]
default = [
"bitmap_backend",
@@ -111,6 +113,7 @@ default = [
"all_series",
"all_elements",
"full_palette",
+ "colormaps",
]
deprecated_items = []
errorbar = []
@@ -153,6 +156,10 @@ features = [
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))".dev-dependencies.wasm-bindgen-test]
version = "0.3.24"
+[target."cfg(not(all(target_arch = \"wasm32\", not(target_os = \"wasi\"))))".dependencies.ab_glyph]
+version = "0.2.12"
+optional = true
+
[target."cfg(not(all(target_arch = \"wasm32\", not(target_os = \"wasi\"))))".dependencies.font-kit]
version = "0.11.0"
optional = true
@@ -171,12 +178,16 @@ default-features = false
version = "1.4.0"
optional = true
+[target."cfg(not(all(target_arch = \"wasm32\", not(target_os = \"wasi\"))))".dependencies.once_cell]
+version = "1.8.0"
+optional = true
+
[target."cfg(not(all(target_arch = \"wasm32\", not(target_os = \"wasi\"))))".dependencies.pathfinder_geometry]
version = "0.5.1"
optional = true
[target."cfg(not(all(target_arch = \"wasm32\", not(target_os = \"wasi\"))))".dependencies.ttf-parser]
-version = "0.15.0"
+version = "0.17.0"
optional = true
[target."cfg(not(target_arch = \"wasm32\"))".dev-dependencies.rand]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index d62f4f9..7ba56ac 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "plotters"
-version = "0.3.4"
+version = "0.3.5"
authors = ["Hao Hou <haohou302@gmail.com>"]
edition = "2018"
license = "MIT"
@@ -17,25 +17,28 @@ num-traits = "0.2.14"
chrono = { version = "0.4.20", optional = true }
[dependencies.plotters-backend]
-#path = "../plotters-backend"
-version = "0.3"
+version = "0.3.5"
+path = "../plotters-backend"
[dependencies.plotters-bitmap]
+version = "0.3.3"
default_features = false
optional = true
-#path = "../plotters-bitmap"
-version = "0.3"
+path = "../plotters-bitmap"
[dependencies.plotters-svg]
-version = "^0.3"
+version = "0.3.5"
optional = true
-#path = "../plotters-svg"
+path = "../plotters-svg"
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))'.dependencies]
-ttf-parser = { version = "0.15.0", optional = true }
+ttf-parser = { version = "0.17.0", optional = true }
lazy_static = { version = "1.4.0", optional = true }
pathfinder_geometry = { version = "0.5.1", optional = true }
font-kit = { version = "0.11.0", optional = true }
+ab_glyph = { version = "0.2.12", optional = true }
+once_cell = { version = "1.8.0", optional = true }
+
[target.'cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"))))'.dependencies.image]
version = "0.24.3"
@@ -67,19 +70,21 @@ default = [
"ttf",
"image",
"deprecated_items", "all_series", "all_elements",
- "full_palette"
+ "full_palette",
+ "colormaps"
]
all_series = ["area_series", "line_series", "point_series", "surface_series"]
all_elements = ["errorbar", "candlestick", "boxplot", "histogram"]
# Tier 1 Backends
-bitmap_backend = ["plotters-bitmap", "ttf"]
+bitmap_backend = ["plotters-bitmap"]
bitmap_encoder = ["plotters-bitmap/image_encoder"]
bitmap_gif = ["plotters-bitmap/gif_backend"]
svg_backend = ["plotters-svg"]
# Colors
full_palette = []
+colormaps = []
# Elements
errorbar = []
@@ -99,6 +104,8 @@ ttf = ["font-kit", "ttf-parser", "lazy_static", "pathfinder_geometry"]
# Can be useful for cross compiling, especially considering fontconfig has lots of C dependencies
fontconfig-dlopen = ["font-kit/source-fontconfig-dlopen"]
+ab_glyph = ["dep:ab_glyph", "once_cell"]
+
# Misc
datetime = ["chrono"]
evcxr = ["svg_backend"]
@@ -107,7 +114,7 @@ deprecated_items = [] # Keep some of the deprecated items for backward compatibi
[dev-dependencies]
itertools = "0.10.0"
-criterion = "0.3.6"
+criterion = "0.4.0"
rayon = "1.5.1"
serde_json = "1.0.82"
serde = "1.0.139"
diff --git a/LICENSE b/LICENSE
index 905e4b2..ea5b606 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1 @@
-MIT License
-
-Copyright (c) 2019 Hao Hou <haohou302@gmail.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+../LICENSE \ No newline at end of file
diff --git a/METADATA b/METADATA
index da23aa1..514b5f7 100644
--- a/METADATA
+++ b/METADATA
@@ -1,23 +1,20 @@
# This project was upgraded with external_updater.
-# Usage: tools/external_updater/updater.sh update rust/crates/plotters
-# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+# Usage: tools/external_updater/updater.sh update external/rust/crates/plotters
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
name: "plotters"
description: "A Rust drawing library focus on data plotting for both WASM and native applications"
third_party {
- url {
- type: HOMEPAGE
- value: "https://crates.io/crates/plotters"
- }
- url {
- type: ARCHIVE
- value: "https://static.crates.io/crates/plotters/plotters-0.3.4.crate"
- }
- version: "0.3.4"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 12
- day: 13
+ year: 2024
+ month: 2
+ day: 5
+ }
+ homepage: "https://crates.io/crates/plotters"
+ identifier {
+ type: "Archive"
+ value: "https://static.crates.io/crates/plotters/plotters-0.3.5.crate"
+ version: "0.3.5"
}
}
diff --git a/README.md b/README.md
index fa451dd..32d46ee 100644
--- a/README.md
+++ b/README.md
@@ -1,601 +1 @@
-# Plotters - A Rust drawing library focus on data plotting for both WASM and native applications 🦀📈🚀
-
-<a href="https://crates.io/crates/plotters">
- <img style="display: inline!important" src="https://img.shields.io/crates/v/plotters.svg"></img>
-</a>
-<a href="https://docs.rs/plotters">
- <img style="display: inline!important" src="https://docs.rs/plotters/badge.svg"></img>
-</a>
-<a href="https://docs.rs/plotters">
- <img style="display: inline!important" src="https://img.shields.io/crates/d/plotters"></img>
-</a>
-<a href="https://plotters-rs.github.io/rustdoc/plotters/">
- <img style="display: inline! important" src="https://img.shields.io/badge/docs-development-lightgrey.svg"></img>
-</a>
-
-Plotters is drawing library designed for rendering figures, plots, and charts, in pure rust. Plotters supports various types of back-ends,
-including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
-
-- A new Plotters Developer's Guide is working in progress. The preview version is available at [here](https://plotters-rs.github.io/book).
-- To try Plotters with interactive Jupyter notebook, or view [here](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html) for the static HTML version.
-- To view the WASM example, go to this [link](https://plotters-rs.github.io/wasm-demo/www/index.html)
-- Currently we have all the internal code ready for console plotting, but a console based backend is still not ready. See [this example](https://github.com/38/plotters/blob/master/examples/console.rs) for how to plotting on Console with a customized backend.
-- Plotters now moved all backend code to sperate repositories, check [FAQ list](#faq-list) for details
-- Some interesting [demo projects](#demo-projects) are available, feel free to try them out.
-
-## Gallery
-
-To view the source code for each example, please click on the example image.
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/chart.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/sample.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/stock.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/stock.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/histogram.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/histogram.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters#quick-start">
- <img src="https://plotters-rs.github.io/plotters-doc-data/0.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="#">
- <img src="https://plotters-rs.github.io/plotters-doc-data/console-2.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/mandelbrot.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/mandelbrot.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters#trying-with-jupyter-evcxr-kernel-interactively">
- <img src="https://plotters-rs.github.io/plotters-doc-data/evcxr_animation.gif" class="galleryItem" width=200px></img>
-</a>
-
-
-<a href="https://github.com/plotters-rs/plotters-piston/blob/master/plotters/examples/cpustat.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/plotters-piston.gif" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/normal-dist.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/normal-dist.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/two-scales.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/twoscale.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/matshow.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/matshow.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/sierpinski.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/sierpinski.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/normal-dist2.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/normal-dist2.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/errorbar.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/errorbar.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/slc-temp.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/slc-temp.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/area-chart.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/area-chart.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/snowflake.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/snowflake.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/animation.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/animation.gif" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/console.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/console-example.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/console.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/console.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/blit-bitmap.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/blit-bitmap.png" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/boxplot.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/boxplot.svg" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/3d-plot.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/3d-plot.svg" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/3d-plot2.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/3d-plot2.gif" class="galleryItem" width=200px></img>
-</a>
-
-<a href="https://github.com/38/plotters/blob/master/plotters/examples/tick_control.rs">
- <img src="https://plotters-rs.github.io/plotters-doc-data/tick_control.svg" class="galleryItem" width=200px></img>
-</a>
-
-
-## Table of Contents
- * [Gallery](#gallery)
- * [Dependencies](#dependencies)
- + [Ubuntu Linux](#ubuntu-linux)
- * [Quick Start](#quick-start)
- * [Demo Projects](#demo-projects)
- * [Trying with Jupyter evcxr Kernel Interactively](#trying-with-jupyter-evcxr-kernel-interactively)
- * [Interactive Tutorial with Jupyter Notebook](#interactive-tutorial-with-jupyter-notebook)
- * [Plotting in Rust](#plotting-in-rust)
- * [Plotting on HTML5 canvas with WASM Backend](#plotting-on-html5-canvas-with-wasm-backend)
- * [What types of figure are supported?](#what-types-of-figure-are-supported)
- * [Concepts by examples](#concepts-by-examples)
- + [Drawing Back-ends](#drawing-back-ends)
- + [Drawing Area](#drawing-area)
- + [Elements](#elements)
- + [Composable Elements](#composable-elements)
- + [Chart Context](#chart-context)
- * [Misc](#misc)
- + [Development Version](#development-version)
- + [Reducing Depending Libraries && Turning Off Backends](#reducing-depending-libraries--turning-off-backends)
- + [List of Features](#list-of-features)
- * [FAQ List](#faq-list)
-
-## Dependencies
-
-### Ubuntu Linux
-
- ```sudo apt install pkg-config libfreetype6-dev libfontconfig1-dev```
-
-## Quick Start
-
-To use Plotters, you can simply add Plotters into your `Cargo.toml`
-```toml
-[dependencies]
-plotters = "0.3.1"
-```
-
-And the following code draws a quadratic function. `src/main.rs`,
-
-```rust
-use plotters::prelude::*;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root = BitMapBackend::new("plotters-doc-data/0.png", (640, 480)).into_drawing_area();
- root.fill(&WHITE)?;
- let mut chart = ChartBuilder::on(&root)
- .caption("y=x^2", ("sans-serif", 50).into_font())
- .margin(5)
- .x_label_area_size(30)
- .y_label_area_size(30)
- .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
-
- chart.configure_mesh().draw()?;
-
- chart
- .draw_series(LineSeries::new(
- (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)),
- &RED,
- ))?
- .label("y = x^2")
- .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 20, y)], &RED));
-
- chart
- .configure_series_labels()
- .background_style(&WHITE.mix(0.8))
- .border_style(&BLACK)
- .draw()?;
-
- root.present()?;
-
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/0.png)
-
-## Demo Projects
-
-To learn how to use Plotters in different scenarios by checking out the following demo projects:
-
-- WebAssembly + Plotters: [plotters-wasm-demo](https://github.com/plotters-rs/plotters-wasm-demo)
-- minifb + Plotters: [plotters-minifb-demo](https://github.com/plotters-rs/plotters-minifb-demo)
-- GTK + Plotters: [plotters-gtk-demo](https://github.com/plotters-rs/plotters-gtk-demo)
-
-
-## Trying with Jupyter evcxr Kernel Interactively
-
-Plotters now supports integrate with `evcxr` and is able to interactively drawing plots in Jupyter Notebook.
-The feature `evcxr` should be enabled when including Plotters to Jupyter Notebook.
-
-The following code shows a minimal example of this.
-
-```text
-:dep plotters = { git = "https://github.com/38/plotters", default_features = false, features = ["evcxr"] }
-extern crate plotters;
-use plotters::prelude::*;
-
-let figure = evcxr_figure((640, 480), |root| {
- root.fill(&WHITE)?;
- let mut chart = ChartBuilder::on(&root)
- .caption("y=x^2", ("Arial", 50).into_font())
- .margin(5)
- .x_label_area_size(30)
- .y_label_area_size(30)
- .build_cartesian_2d(-1f32..1f32, -0.1f32..1f32)?;
-
- chart.configure_mesh().draw()?;
-
- chart.draw_series(LineSeries::new(
- (-50..=50).map(|x| x as f32 / 50.0).map(|x| (x, x * x)),
- &RED,
- )).unwrap()
- .label("y = x^2")
- .legend(|(x,y)| PathElement::new(vec![(x,y), (x + 20,y)], &RED));
-
- chart.configure_series_labels()
- .background_style(&WHITE.mix(0.8))
- .border_style(&BLACK)
- .draw()?;
- Ok(())
-});
-figure
-```
-
-<img src="https://plotters-rs.github.io/plotters-doc-data/evcxr_animation.gif" width="450px"></img>
-
-## Interactive Tutorial with Jupyter Notebook
-
-*This tutorial is now working in progress and isn't complete*
-
-Thanks to the evcxr, now we have an interactive tutorial for Plotters!
-To use the interactive notebook, you must have Jupyter and evcxr installed on your computer.
-Follow the instruction on [this page](https://github.com/google/evcxr/tree/master/evcxr_jupyter) below to install it.
-
-After that, you should be able to start your Jupyter server locally and load the tutorial!
-
-```bash
-git clone https://github.com/38/plotters-doc-data
-cd plotteres-doc-data
-jupyter notebook
-```
-
-And select the notebook called `evcxr-jupyter-integration.ipynb`.
-
-Also, there's a static HTML version of this notebook available at the [this location](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html)
-
-## Plotting in Rust
-
-Rust is a perfect language for data visualization. Although there are many mature visualization libraries in many different languages.
-But Rust is one of the best languages fits the need.
-
-* **Easy to use** Rust has a very good iterator system built into the standard library. With the help of iterators,
-Plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library
-can be very easy to use.
-
-* **Fast** If you need rendering a figure with trillions of data points,
-Rust is a good choice. Rust's performance allows you to combine data processing step
-and rendering step into a single application. When plotting in high-level programming languages,
-e.g. Javascript or Python, data points must be down-sampled before feeding into the plotting
-program because of the performance considerations. Rust is fast enough to do the data processing and visualization
-within a single program. You can also integrate the
-figure rendering code into your application handling a huge amount of data and visualize it in real-time.
-
-* **WebAssembly Support** Rust is one of few the language with the best WASM support. Plotting in Rust could be
-very useful for visualization on a web page and would have a huge performance improvement comparing to Javascript.
-
-## Plotting on HTML5 canvas with WASM Backend
-
-Plotters currently supports backend that uses the HTML5 canvas. To use the WASM support, you can simply use
-`CanvasBackend` instead of other backend and all other API remains the same!
-
-There's a small demo for Plotters + WASM available at [here](https://github.com/plotters-rs/plotters-wasm-demo).
-To play with the deployed version, follow this [link](https://plotters-rs.github.io/wasm-demo/www/index.html).
-
-
-## What types of figure are supported?
-
-Plotters is not limited to any specific type of figure.
-You can create your own types of figures easily with the Plotters API.
-
-But Plotters provides some builtin figure types for convenience.
-Currently, we support line series, point series, candlestick series, and histogram.
-And the library is designed to be able to render multiple figure into a single image.
-But Plotter is aimed to be a platform that is fully extendable to support any other types of figure.
-
-## Concepts by examples
-
-### Drawing Back-ends
-Plotters can use different drawing back-ends, including SVG, BitMap, and even real-time rendering. For example, a bitmap drawing backend.
-
-```rust
-use plotters::prelude::*;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- // Create a 800*600 bitmap and start drawing
- let mut backend = BitMapBackend::new("plotters-doc-data/1.png", (300, 200));
- // And if we want SVG backend
- // let backend = SVGBackend::new("output.svg", (800, 600));
- backend.draw_rect((50, 50), (200, 150), &RED, true)?;
- backend.present()?;
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/1.png)
-
-### Drawing Area
-Plotters uses a concept called drawing area for layout purpose.
-Plotters support multiple integrating into a single image.
-This is done by creating sub-drawing-areas.
-
-Besides that, the drawing area also allows the customized coordinate system, by doing so, the coordinate mapping is done by the drawing area automatically.
-
-```rust
-use plotters::prelude::*;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root_drawing_area =
- BitMapBackend::new("plotters-doc-data/2.png", (300, 200)).into_drawing_area();
- // And we can split the drawing area into 3x3 grid
- let child_drawing_areas = root_drawing_area.split_evenly((3, 3));
- // Then we fill the drawing area with different color
- for (area, color) in child_drawing_areas.into_iter().zip(0..) {
- area.fill(&Palette99::pick(color))?;
- }
- root_drawing_area.present()?;
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/2.png)
-
-### Elements
-
-In Plotters, elements are build blocks of figures. All elements are able to draw on a drawing area.
-There are different types of built-in elements, like lines, texts, circles, etc.
-You can also define your own element in the application code.
-
-You may also combine existing elements to build a complex element.
-
-To learn more about the element system, please read the [element module documentation](./element/index.html).
-
-```rust
-use plotters::prelude::*;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root = BitMapBackend::new("plotters-doc-data/3.png", (300, 200)).into_drawing_area();
- root.fill(&WHITE)?;
- // Draw an circle on the drawing area
- root.draw(&Circle::new(
- (100, 100),
- 50,
- Into::<ShapeStyle>::into(&GREEN).filled(),
- ))?;
- root.present()?;
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/3.png)
-
-### Composable Elements
-
-Besides the built-in elements, elements can be composed into a logic group we called composed elements.
-When composing new elements, the upper-left corner is given in the target coordinate, and a new pixel-based
-coordinate which has the upper-left corner defined as `(0,0)` is used for further element composition purpose.
-
-For example, we can have an element which includes a dot and its coordinate.
-
-```rust
-use plotters::prelude::*;
-use plotters::coord::types::RangedCoordf32;
-
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root = BitMapBackend::new("plotters-doc-data/4.png", (640, 480)).into_drawing_area();
-
- root.fill(&RGBColor(240, 200, 200))?;
-
- let root = root.apply_coord_spec(Cartesian2d::<RangedCoordf32, RangedCoordf32>::new(
- 0f32..1f32,
- 0f32..1f32,
- (0..640, 0..480),
- ));
-
- let dot_and_label = |x: f32, y: f32| {
- return EmptyElement::at((x, y))
- + Circle::new((0, 0), 3, ShapeStyle::from(&BLACK).filled())
- + Text::new(
- format!("({:.2},{:.2})", x, y),
- (10, 0),
- ("sans-serif", 15.0).into_font(),
- );
- };
-
- root.draw(&dot_and_label(0.5, 0.6))?;
- root.draw(&dot_and_label(0.25, 0.33))?;
- root.draw(&dot_and_label(0.8, 0.8))?;
- root.present()?;
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/4.png)
-
-### Chart Context
-
-In order to draw a chart, Plotters need a data object built on top of the drawing area called `ChartContext`.
-The chart context defines even higher level constructs compare to the drawing area.
-For example, you can define the label areas, meshes, and put a data series onto the drawing area with the help
-of the chart context object.
-
-```rust
-use plotters::prelude::*;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let root = BitMapBackend::new("plotters-doc-data/5.png", (640, 480)).into_drawing_area();
- root.fill(&WHITE);
- let root = root.margin(10, 10, 10, 10);
- // After this point, we should be able to draw construct a chart context
- let mut chart = ChartBuilder::on(&root)
- // Set the caption of the chart
- .caption("This is our first plot", ("sans-serif", 40).into_font())
- // Set the size of the label region
- .x_label_area_size(20)
- .y_label_area_size(40)
- // Finally attach a coordinate on the drawing area and make a chart context
- .build_cartesian_2d(0f32..10f32, 0f32..10f32)?;
-
- // Then we can draw a mesh
- chart
- .configure_mesh()
- // We can customize the maximum number of labels allowed for each axis
- .x_labels(5)
- .y_labels(5)
- // We can also change the format of the label text
- .y_label_formatter(&|x| format!("{:.3}", x))
- .draw()?;
-
- // And we can draw something in the drawing area
- chart.draw_series(LineSeries::new(
- vec![(0.0, 0.0), (5.0, 5.0), (8.0, 7.0)],
- &RED,
- ))?;
- // Similarly, we can draw point series
- chart.draw_series(PointSeries::of_element(
- vec![(0.0, 0.0), (5.0, 5.0), (8.0, 7.0)],
- 5,
- &RED,
- &|c, s, st| {
- return EmptyElement::at(c) // We want to construct a composed element on-the-fly
- + Circle::new((0,0),s,st.filled()) // At this point, the new pixel coordinate is established
- + Text::new(format!("{:?}", c), (10, 0), ("sans-serif", 10).into_font());
- },
- ))?;
- root.present()?;
- Ok(())
-}
-```
-
-![](https://plotters-rs.github.io/plotters-doc-data/5.png)
-
-## Misc
-
-### Development Version
-
-Find the latest development version of Plotters on [GitHub](https://github.com/38/plotters.git).
-Clone the repository and learn more about the Plotters API and ways to contribute. Your help is needed!
-
-If you want to add the development version of Plotters to your project, add the following to your `Cargo.toml`:
-
-```toml
-[dependencies]
-plotters = { git = "https://github.com/38/plotters.git" }
-```
-
-### Reducing Depending Libraries && Turning Off Backends
-Plotters now supports use features to control the backend dependencies. By default, `BitMapBackend` and `SVGBackend` are supported,
-use `default_features = false` in the dependency description in `Cargo.toml` and you can cherry-pick the backend implementations.
-
-- `svg` Enable the `SVGBackend`
-- `bitmap` Enable the `BitMapBackend`
-
-For example, the following dependency description would avoid compiling with bitmap support:
-
-```toml
-[dependencies]
-plotters = { git = "https://github.com/38/plotters.git", default_features = false, features = ["svg"] }
-```
-
-The library also allows consumers to make use of the [`Palette`](https://crates.io/crates/palette/) crate's color types by default.
-This behavior can also be turned off by setting `default_features = false`.
-
-### List of Features
-
-This is the full list of features that is defined by `Plotters` crate.
-Use `default_features = false` to disable those default enabled features,
-and then you should be able to cherry-pick what features you want to include into `Plotters` crate.
-By doing so, you can minimize the number of dependencies down to only `itertools` and compile time is less than 6s.
-
-The following list is a complete list of features that can be opt in and out.
-
-- Tier 1 drawing backends
-
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| bitmap\_encoder | Allow `BitMapBackend` save the result to bitmap files | image, rusttype, font-kit | Yes |
-| svg\_backend | Enable `SVGBackend` Support | None | Yes |
-| bitmap\_gif| Opt-in GIF animation Rendering support for `BitMapBackend`, implies `bitmap` enabled | gif | Yes |
-
-- Font manipulation features
-
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| ttf | Allows TrueType font support | rusttype, font-kit | Yes |
-
-- Coordinate features
-
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| datetime | Enable the date and time coordinate support | chrono | Yes |
-
-- Element, series and util functions
-
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| errorbar | The errorbar element support | None | Yes |
-| candlestick | The candlestick element support | None | Yes |
-| boxplot | The boxplot element support | None | Yes |
-| area\_series | The area series support | None | Yes |
-| line\_series | The line series support | None | Yes |
-| histogram | The histogram series support | None | Yes |
-| point\_series| The point series support | None | Yes |
-
-- Misc
-
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| deprecated\_items | This feature allows use of deprecated items which is going to be removed in the future | None | Yes |
-| debug | Enable the code used for debugging | None | No |
-
-
-## FAQ List
-
-* Why does the WASM example break on my machine ?
-
- The WASM example requires using `wasm32` target to build. Using `cargo build` is likely to use the default target
- which in most of the case is any of the x86 target. Thus you need add `--target=wasm32-unknown-unknown` in the cargo
- parameter list to build it.
-
-* How to draw text/circle/point/rectangle/... on the top of chart ?
-
- As you may realized, Plotters is a drawing library rather than a traditional data plotting library,
- you have the freedom to draw anything you want on the drawing area.
- Use `DrawingArea::draw` to draw any element on the drawing area.
-
-* Where can I find the backend code ?
-
- Since Plotters 0.3, all drawing backends are independent crate from the main Plotters crate.
- Use the following link to find the backend code:
-
- - [Bitmap Backend](https://github.com/plotters-rs/plotters-bitmap.git)
- - [SVG Backend](https://github.com/plotters-rs/plotters-svg.git)
- - [HTML5 Canvas Backend](https://github.com/plotters-rs/plotters-canvas.git)
- - [GTK/Cairo Backend](https://github.com/plotters-rs/plotters-cairo.git)
-
-* How to check if a backend writes file successfully ?
-
- The behavior of Plotters backend is consistent with standard library.
- When the backend instance is being dropped, [`crate::drawing::DrawingArea::present()`] or `Backend::present()` is called automatically
- whenever is needed. When the `present()` method is called from `drop`, any error will be silently ignored.
-
- In the case that error handling is important, you need manually call the `present()` method before the backend gets dropped.
- For more information, please see the examples.
-
-
+../README.md \ No newline at end of file
diff --git a/examples/3d-plot2.rs b/examples/3d-plot2.rs
index 0b5ca21..b7138f2 100644
--- a/examples/3d-plot2.rs
+++ b/examples/3d-plot2.rs
@@ -36,9 +36,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
(-15..=15).map(|x| x as f64 / 5.0),
pdf,
)
- .style_func(&|&v| {
- (&HSLColor(240.0 / 360.0 - 240.0 / 360.0 * v / 5.0, 1.0, 0.7)).into()
- }),
+ .style_func(&|&v| (VulcanoHSL::get_color(v / 5.0)).into()),
)?;
root.present()?;
diff --git a/examples/colormaps.rs b/examples/colormaps.rs
new file mode 100644
index 0000000..4c8cc4d
--- /dev/null
+++ b/examples/colormaps.rs
@@ -0,0 +1,69 @@
+use plotters::prelude::*;
+
+const OUT_FILE_NAME: &'static str = "plotters-doc-data/colormaps.png";
+
+fn main() -> Result<(), Box<dyn std::error::Error>> {
+ let colormaps_rgb: [(Box<dyn ColorMap<RGBColor>>, &str); 4] = [
+ (Box::new(ViridisRGB {}), "Viridis"),
+ (Box::new(BlackWhite {}), "BlackWhite"),
+ (Box::new(Bone {}), "Bone"),
+ (Box::new(Copper {}), "Copper"),
+ ];
+
+ let colormaps_hsl: [(Box<dyn ColorMap<HSLColor>>, &str); 2] = [
+ (Box::new(MandelbrotHSL {}), "MandelbrotHSL"),
+ (Box::new(VulcanoHSL {}), "VulcanoHSL"),
+ ];
+
+ let size_x: i32 = 800;
+ let n_colormaps = colormaps_rgb.len() + colormaps_hsl.len();
+ let size_y = 200 + n_colormaps as u32 * 100;
+ let root = BitMapBackend::new(OUT_FILE_NAME, (size_x as u32, size_y)).into_drawing_area();
+
+ root.fill(&WHITE)?;
+
+ let mut chart = ChartBuilder::on(&root)
+ .caption("Demonstration of predefined colormaps", ("sans-serif", 20))
+ .build_cartesian_2d(
+ -150.0..size_x as f32 + 50.0,
+ 0.0..3.0 * (n_colormaps as f32),
+ )?;
+
+ use plotters::style::text_anchor::*;
+ let centered = Pos::new(HPos::Center, VPos::Center);
+ let label_style = TextStyle::from(("monospace", 14.0).into_font()).pos(centered);
+
+ let mut colormap_counter = 0;
+ macro_rules! plot_colormaps(
+ ($colormap:expr) => {
+ for (colormap, colormap_name) in $colormap.iter() {
+ chart.draw_series(
+ (0..size_x as i32).map(|x| {
+ Rectangle::new([
+ (x as f32, 3.0*(n_colormaps - 1 - colormap_counter) as f32 + 0.5),
+ (x as f32+1.0, 3.0*(n_colormaps - 1 - colormap_counter) as f32 + 2.5)
+ ],
+ colormap.get_color_normalized(x as f32, 0.0, size_x as f32).filled())
+ })
+ )?;
+ chart.draw_series(
+ [Text::new(colormap_name.to_owned(), (-75.0, 3.0*(n_colormaps-1-colormap_counter) as f32 + 1.5), &label_style)]
+ )?;
+ colormap_counter+=1;
+ }
+ }
+ );
+
+ plot_colormaps!(colormaps_rgb);
+ plot_colormaps!(colormaps_hsl);
+
+ // To avoid the IO failure being ignored silently, we manually call the present function
+ root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
+ println!("Result has been saved to {}", OUT_FILE_NAME);
+
+ Ok(())
+}
+#[test]
+fn entry_point() {
+ main().unwrap()
+}
diff --git a/examples/mandelbrot.rs b/examples/mandelbrot.rs
index 413c319..b0d5799 100644
--- a/examples/mandelbrot.rs
+++ b/examples/mandelbrot.rs
@@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
for (x, y, c) in mandelbrot_set(xr, yr, (pw as usize, ph as usize), 100) {
if c != 100 {
- plotting_area.draw_pixel((x, y), &HSLColor(c as f64 / 100.0, 1.0, 0.5))?;
+ plotting_area.draw_pixel((x, y), &MandelbrotHSL::get_color(c as f64 / 100.0))?;
} else {
plotting_area.draw_pixel((x, y), &BLACK)?;
}
diff --git a/src/chart/context/cartesian2d/draw_impl.rs b/src/chart/context/cartesian2d/draw_impl.rs
index 6dafa08..1745273 100644
--- a/src/chart/context/cartesian2d/draw_impl.rs
+++ b/src/chart/context/cartesian2d/draw_impl.rs
@@ -119,10 +119,7 @@ impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged> ChartContext<'a, DB, Cartesia
y1 = axis_range.end;
}
- area.draw(&PathElement::new(
- vec![(x0, y0), (x1, y1)],
- *axis_style,
- ))?;
+ area.draw(&PathElement::new(vec![(x0, y0), (x1, y1)], *axis_style))?;
}
Ok(axis_range)
diff --git a/src/chart/dual_coord.rs b/src/chart/dual_coord.rs
index d5960e0..434e347 100644
--- a/src/chart/dual_coord.rs
+++ b/src/chart/dual_coord.rs
@@ -20,7 +20,7 @@ use plotters_backend::{BackendCoord, DrawingBackend};
/// This situation is quite common, for example, we with two different coodinate system.
/// For instance this example <img src="https://plotters-rs.github.io/plotters-doc-data/twoscale.png"></img>
/// This is done by attaching a second coordinate system to ChartContext by method [ChartContext::set_secondary_coord](struct.ChartContext.html#method.set_secondary_coord).
-/// For instance of dual coordinate charts, see [this example](https://github.com/38/plotters/blob/master/examples/two-scales.rs#L15).
+/// For instance of dual coordinate charts, see [this example](https://github.com/plotters-rs/plotters/blob/master/examples/two-scales.rs#L15).
/// Note: `DualCoordChartContext` is always deref to the chart context.
/// - If you want to configure the secondary axis, method [DualCoordChartContext::configure_secondary_axes](struct.DualCoordChartContext.html#method.configure_secondary_axes)
/// - If you want to draw a series using secondary coordinate system, use [DualCoordChartContext::draw_secondary_series](struct.DualCoordChartContext.html#method.draw_secondary_series). And method [ChartContext::draw_series](struct.ChartContext.html#method.draw_series) will always use primary coordinate spec.
diff --git a/src/chart/series.rs b/src/chart/series.rs
index 8c430cb..4aecf6a 100644
--- a/src/chart/series.rs
+++ b/src/chart/series.rs
@@ -250,9 +250,7 @@ impl<'a, 'b, DB: DrawingBackend + 'a, CT: CoordTranslate> SeriesLabelStyle<'a, '
continue;
}
- funcs.push(
- draw_func.unwrap_or(&|p: BackendCoord| EmptyElement::at(p).into_dyn()),
- );
+ funcs.push(draw_func.unwrap_or(&|p: BackendCoord| EmptyElement::at(p).into_dyn()));
label_element.push_line(label_text);
}
diff --git a/src/coord/ranged1d/types/datetime.rs b/src/coord/ranged1d/types/datetime.rs
index 9b12358..0a532f8 100644
--- a/src/coord/ranged1d/types/datetime.rs
+++ b/src/coord/ranged1d/types/datetime.rs
@@ -4,12 +4,12 @@ use std::ops::{Add, Range, Sub};
use crate::coord::ranged1d::{
AsRangedCoord, DefaultFormatting, DiscreteRanged, KeyPointHint, NoDefaultFormatting, Ranged,
- ValueFormatter,
+ ReversibleRanged, ValueFormatter,
};
/// The trait that describe some time value. This is the uniformed abstraction that works
/// for both Date, DateTime and Duration, etc.
-pub trait TimeValue: Eq {
+pub trait TimeValue: Eq + Sized {
type DateType: Datelike + PartialOrd;
/// Returns the date that is no later than the time
@@ -20,6 +20,8 @@ pub trait TimeValue: Eq {
fn earliest_after_date(date: Self::DateType) -> Self;
/// Returns the duration between two time value
fn subtract(&self, other: &Self) -> Duration;
+ /// Add duration to time value
+ fn add(&self, duration: &Duration) -> Self;
/// Instantiate a date type for current time value;
fn ymd(&self, year: i32, month: u32, date: u32) -> Self::DateType;
/// Cast current date type into this type
@@ -46,6 +48,31 @@ pub trait TimeValue: Eq {
(f64::from(limit.1 - limit.0) * value_days / total_days) as i32 + limit.0
}
+
+ /// Map pixel to coord spec
+ fn unmap_coord(point: i32, begin: &Self, end: &Self, limit: (i32, i32)) -> Self {
+ let total_span = end.subtract(begin);
+ let offset = (point - limit.0) as i64;
+
+ // Check if nanoseconds fit in i64
+ if let Some(total_ns) = total_span.num_nanoseconds() {
+ let pixel_span = (limit.1 - limit.0) as i64;
+ let factor = total_ns / pixel_span;
+ let remainder = total_ns % pixel_span;
+ if factor == 0
+ || i64::MAX / factor > offset.abs()
+ || (remainder == 0 && i64::MAX / factor >= offset.abs())
+ {
+ let nano_seconds = offset * factor + (remainder * offset) / pixel_span;
+ return begin.add(&Duration::nanoseconds(nano_seconds));
+ }
+ }
+
+ // Otherwise, use days
+ let total_days = total_span.num_days() as f64;
+ let days = (((offset as f64) * total_days) / ((limit.1 - limit.0) as f64)) as i64;
+ begin.add(&Duration::days(days))
+ }
}
impl TimeValue for NaiveDate {
@@ -62,6 +89,9 @@ impl TimeValue for NaiveDate {
fn subtract(&self, other: &NaiveDate) -> Duration {
*self - *other
}
+ fn add(&self, other: &Duration) -> NaiveDate {
+ *self + *other
+ }
fn ymd(&self, year: i32, month: u32, date: u32) -> Self::DateType {
NaiveDate::from_ymd(year, month, date)
@@ -86,6 +116,9 @@ impl<Z: TimeZone> TimeValue for Date<Z> {
fn subtract(&self, other: &Date<Z>) -> Duration {
self.clone() - other.clone()
}
+ fn add(&self, other: &Duration) -> Date<Z> {
+ self.clone() + *other
+ }
fn ymd(&self, year: i32, month: u32, date: u32) -> Self::DateType {
self.timezone().ymd(year, month, date)
@@ -115,6 +148,9 @@ impl<Z: TimeZone> TimeValue for DateTime<Z> {
fn subtract(&self, other: &DateTime<Z>) -> Duration {
self.clone() - other.clone()
}
+ fn add(&self, other: &Duration) -> DateTime<Z> {
+ self.clone() + *other
+ }
fn ymd(&self, year: i32, month: u32, date: u32) -> Self::DateType {
self.timezone().ymd(year, month, date)
@@ -144,6 +180,9 @@ impl TimeValue for NaiveDateTime {
fn subtract(&self, other: &NaiveDateTime) -> Duration {
*self - *other
}
+ fn add(&self, other: &Duration) -> NaiveDateTime {
+ *self + *other
+ }
fn ymd(&self, year: i32, month: u32, date: u32) -> Self::DateType {
NaiveDate::from_ymd(year, month, date)
@@ -663,6 +702,19 @@ where
}
}
+impl<DT> ReversibleRanged for RangedDateTime<DT>
+where
+ DT: Datelike + Timelike + TimeValue + Clone + PartialOrd,
+ DT: Add<Duration, Output = DT>,
+ DT: Sub<DT, Output = Duration>,
+ RangedDate<DT::DateType>: Ranged<ValueType = DT::DateType>,
+{
+ /// Perform the reverse mapping
+ fn unmap(&self, input: i32, limit: (i32, i32)) -> Option<Self::ValueType> {
+ Some(TimeValue::unmap_coord(input, &self.0, &self.1, limit))
+ }
+}
+
/// The coordinate that for duration of time
#[derive(Clone)]
pub struct RangedDuration(Duration, Duration);
@@ -1168,4 +1220,76 @@ mod test {
assert_eq!(coord1.index_of(&coord1.from_index(i).unwrap()).unwrap(), i);
}
}
+
+ #[test]
+ fn test_datetime_with_unmap() {
+ let start_time = Utc.ymd(2021, 1, 1).and_hms(8, 0, 0);
+ let end_time = Utc.ymd(2023, 1, 1).and_hms(8, 0, 0);
+ let mid = Utc.ymd(2022, 1, 1).and_hms(8, 0, 0);
+ let coord: RangedDateTime<_> = (start_time..end_time).into();
+ let pos = coord.map(&mid, (1000, 2000));
+ assert_eq!(pos, 1500);
+ let value = coord.unmap(pos, (1000, 2000));
+ assert_eq!(value, Some(mid));
+ }
+
+ #[test]
+ fn test_naivedatetime_with_unmap() {
+ let start_time = NaiveDate::from_ymd(2021, 1, 1).and_hms_milli(8, 0, 0, 0);
+ let end_time = NaiveDate::from_ymd(2023, 1, 1).and_hms_milli(8, 0, 0, 0);
+ let mid = NaiveDate::from_ymd(2022, 1, 1).and_hms_milli(8, 0, 0, 0);
+ let coord: RangedDateTime<_> = (start_time..end_time).into();
+ let pos = coord.map(&mid, (1000, 2000));
+ assert_eq!(pos, 1500);
+ let value = coord.unmap(pos, (1000, 2000));
+ assert_eq!(value, Some(mid));
+ }
+
+ #[test]
+ fn test_date_with_unmap() {
+ let start_date = Utc.ymd(2021, 1, 1);
+ let end_date = Utc.ymd(2023, 1, 1);
+ let mid = Utc.ymd(2022, 1, 1);
+ let coord: RangedDate<Date<_>> = (start_date..end_date).into();
+ let pos = coord.map(&mid, (1000, 2000));
+ assert_eq!(pos, 1500);
+ let value = coord.unmap(pos, (1000, 2000));
+ assert_eq!(value, Some(mid));
+ }
+
+ #[test]
+ fn test_naivedate_with_unmap() {
+ let start_date = NaiveDate::from_ymd(2021, 1, 1);
+ let end_date = NaiveDate::from_ymd(2023, 1, 1);
+ let mid = NaiveDate::from_ymd(2022, 1, 1);
+ let coord: RangedDate<NaiveDate> = (start_date..end_date).into();
+ let pos = coord.map(&mid, (1000, 2000));
+ assert_eq!(pos, 1500);
+ let value = coord.unmap(pos, (1000, 2000));
+ assert_eq!(value, Some(mid));
+ }
+
+ #[test]
+ fn test_datetime_unmap_for_nanoseconds() {
+ let start_time = Utc.ymd(2021, 1, 1).and_hms(8, 0, 0);
+ let end_time = start_time + Duration::nanoseconds(1900);
+ let mid = start_time + Duration::nanoseconds(950);
+ let coord: RangedDateTime<_> = (start_time..end_time).into();
+ let pos = coord.map(&mid, (1000, 2000));
+ assert_eq!(pos, 1500);
+ let value = coord.unmap(pos, (1000, 2000));
+ assert_eq!(value, Some(mid));
+ }
+
+ #[test]
+ fn test_datetime_unmap_for_nanoseconds_small_period() {
+ let start_time = Utc.ymd(2021, 1, 1).and_hms(8, 0, 0);
+ let end_time = start_time + Duration::nanoseconds(400);
+ let coord: RangedDateTime<_> = (start_time..end_time).into();
+ let value = coord.unmap(2000, (1000, 2000));
+ assert_eq!(value, Some(end_time));
+ let mid = start_time + Duration::nanoseconds(200);
+ let value = coord.unmap(500, (0, 1000));
+ assert_eq!(value, Some(mid));
+ }
}
diff --git a/src/drawing/area.rs b/src/drawing/area.rs
index 2e5c3fe..9519f37 100644
--- a/src/drawing/area.rs
+++ b/src/drawing/area.rs
@@ -87,7 +87,7 @@ impl Rect {
.map(|(a, b)| (*a, *b))
.collect();
- // Justify: this is actually needed. Because we need to return a iterator that have
+ // Justify: this is actually needed. Because we need to return a iterator that have
// static life time, thus we need to copy the value to a buffer and then turn the buffer
// into a iterator.
#[allow(clippy::needless_collect)]
@@ -97,14 +97,12 @@ impl Rect {
.map(|(a, b)| (*a, *b))
.collect();
- ysegs
- .into_iter()
- .flat_map(move |(y0, y1)| {
- xsegs
- .clone()
- .into_iter()
- .map(move |(x0, x1)| Self { x0, y0, x1, y1 })
- })
+ ysegs.into_iter().flat_map(move |(y0, y1)| {
+ xsegs
+ .clone()
+ .into_iter()
+ .map(move |(x0, x1)| Self { x0, y0, x1, y1 })
+ })
}
/// Make the coordinate in the range of the rectangle
diff --git a/src/element/pie.rs b/src/element/pie.rs
index 9529834..79fa927 100644
--- a/src/element/pie.rs
+++ b/src/element/pie.rs
@@ -109,18 +109,14 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
let radian_increment = PI / 180.0 / self.radius.sqrt() * 2.0;
let mut perc_labels = Vec::new();
for (index, slice) in self.sizes.iter().enumerate() {
- let slice_style =
- self.colors
- .get(index)
- .ok_or_else(|| DrawingErrorKind::FontError(Box::new(
- PieError::LengthMismatch,
- )))?;
+ let slice_style = self
+ .colors
+ .get(index)
+ .ok_or_else(|| DrawingErrorKind::FontError(Box::new(PieError::LengthMismatch)))?;
let label = self
.labels
.get(index)
- .ok_or_else(|| DrawingErrorKind::FontError(Box::new(
- PieError::LengthMismatch,
- )))?;
+ .ok_or_else(|| DrawingErrorKind::FontError(Box::new(PieError::LengthMismatch)))?;
// start building wedge line against the previous edge
let mut points = vec![*self.center];
let ratio = slice / self.total;
diff --git a/src/evcxr.rs b/src/evcxr.rs
index 8117d35..3438d34 100644
--- a/src/evcxr.rs
+++ b/src/evcxr.rs
@@ -53,7 +53,7 @@ pub fn evcxr_bitmap_figure<
size: (u32, u32),
draw: Draw,
) -> SVGWrapper {
- const PIXEL_SIZE : usize = 3;
+ const PIXEL_SIZE: usize = 3;
let mut buf = Vec::new();
buf.resize((size.0 as usize) * (size.1 as usize) * PIXEL_SIZE, 0);
let root = BitMapBackend::with_buffer(&mut buf, size).into_drawing_area();
diff --git a/src/lib.rs b/src/lib.rs
index 873288b..86a75d0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,7 +1,7 @@
#![warn(missing_docs)]
/*!
-# Plotters - A Rust drawing library focus on data plotting for both WASM and native applications 🦀📈🚀
+# Plotters - A Rust drawing library focusing on data plotting for both WASM and native applications 🦀📈🚀
<a href="https://crates.io/crates/plotters">
<img style="display: inline!important" src="https://img.shields.io/crates/v/plotters.svg"></img>
@@ -16,14 +16,14 @@
<img style="display: inline! important" src="https://img.shields.io/badge/docs-development-lightgrey.svg"></img>
</a>
-Plotters is drawing library designed for rendering figures, plots, and charts, in pure rust. Plotters supports various types of back-ends,
+Plotters is a drawing library designed for rendering figures, plots, and charts, in pure Rust. Plotters supports various types of back-ends,
including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
-- A new Plotters Developer's Guide is working in progress. The preview version is available at [here](https://plotters-rs.github.io/book).
-- To try Plotters with interactive Jupyter notebook, or view [here](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html) for the static HTML version.
+- A new Plotters Developer's Guide is a work in progress. The preview version is available [here](https://plotters-rs.github.io/book).
+- Try Plotters with an interactive Jupyter notebook, or view [here](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html) for the static HTML version.
- To view the WASM example, go to this [link](https://plotters-rs.github.io/wasm-demo/www/index.html)
-- Currently we have all the internal code ready for console plotting, but a console based backend is still not ready. See [this example](https://github.com/38/plotters/blob/master/examples/console.rs) for how to plotting on Console with a customized backend.
-- Plotters now moved all backend code to sperate repositories, check [FAQ list](#faq-list) for details
+- Currently we have all the internal code ready for console plotting, but a console based backend is still not ready. See [this example](https://github.com/plotters-rs/plotters/blob/master/plotters/examples/console.rs) for how to plot on console with a customized backend.
+- Plotters has moved all backend code to separate repositories, check [FAQ list](#faq-list) for details
- Some interesting [demo projects](#demo-projects) are available, feel free to try them out.
## Gallery
@@ -34,7 +34,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Multiple Plot
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/chart.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/chart.rs">[code]</a>
</div>
</div>
@@ -44,7 +44,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Candlestick Plot
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/stock.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/stock.rs">[code]</a>
</div>
</div>
@@ -54,7 +54,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Histogram
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/histogram.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/histogram.rs">[code]</a>
</div>
</div>
@@ -82,7 +82,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Mandelbrot set
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/mandelbrot.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/mandelbrot.rs">[code]</a>
</div>
</div>
@@ -112,7 +112,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Histogram with Scatter
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/normal-dist.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/normal-dist.rs">[code]</a>
</div>
</div>
@@ -122,7 +122,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Dual Y-Axis Example
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/two-scales.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/two-scales.rs">[code]</a>
</div>
</div>
@@ -132,7 +132,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
The Matplotlib Matshow Example
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/matshow.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/matshow.rs">[code]</a>
</div>
</div>
@@ -142,7 +142,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
The Sierpinski Carpet
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/sierpinski.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/sierpinski.rs">[code]</a>
</div>
</div>
@@ -152,7 +152,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
The 1D Gaussian Distribution
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/nomal-dist2.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/nomal-dist2.rs">[code]</a>
</div>
</div>
@@ -162,7 +162,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
The 1D Gaussian Distribution
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/errorbar.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/errorbar.rs">[code]</a>
</div>
</div>
@@ -172,7 +172,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Monthly Time Coordinate
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/slc-temp.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/slc-temp.rs">[code]</a>
</div>
</div>
@@ -182,7 +182,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Monthly Time Coordinate
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/area-chart.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/area-chart.rs">[code]</a>
</div>
</div>
@@ -192,7 +192,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Koch Snowflake
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/snowflake.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/snowflake.rs">[code]</a>
</div>
</div>
@@ -203,7 +203,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Koch Snowflake Animation
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/animation.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/animation.rs">[code]</a>
</div>
</div>
@@ -214,7 +214,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Drawing on a Console
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/console.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/console.rs">[code]</a>
</div>
</div>
@@ -224,7 +224,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
Drawing bitmap on chart
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/blit-bitmap.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/blit-bitmap.rs">[code]</a>
</div>
</div>
@@ -234,7 +234,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
The boxplot demo
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/boxplot.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/boxplot.rs">[code]</a>
</div>
</div>
@@ -244,7 +244,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
3D plot rendering
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/3d-plot.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/3d-plot.rs">[code]</a>
</div>
</div>
@@ -254,7 +254,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
2-Var Gussian Distribution PDF
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/3d-plot2.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/3d-plot2.rs">[code]</a>
</div>
</div>
@@ -264,7 +264,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
</a>
<div class="galleryText">
COVID-19 Visualization
- <a href="https://github.com/38/plotters/blob/master/plotters/examples/tick_control.rs">[code]</a>
+ <a href="https://github.com/plotters-rs/plotters/blob/master/plotters/examples/tick_control.rs">[code]</a>
</div>
</div>
@@ -280,8 +280,8 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
* [Plotting in Rust](#plotting-in-rust)
* [Plotting on HTML5 canvas with WASM Backend](#plotting-on-html5-canvas-with-wasm-backend)
* [What types of figure are supported?](#what-types-of-figure-are-supported)
- * [Concepts by examples](#concepts-by-examples)
- + [Drawing Back-ends](#drawing-back-ends)
+ * [Concepts by example](#concepts-by-example)
+ + [Drawing Backends](#drawing-backends)
+ [Drawing Area](#drawing-area)
+ [Elements](#elements)
+ [Composable Elements](#composable-elements)
@@ -303,7 +303,7 @@ including bitmap, vector graph, piston window, GTK/Cairo and WebAssembly.
To use Plotters, you can simply add Plotters into your `Cargo.toml`
```toml
[dependencies]
-plotters = "0.3.1"
+plotters = "0.3.3"
```
And the following code draws a quadratic function. `src/main.rs`,
@@ -346,27 +346,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
## Demo Projects
-To learn how to use Plotters in different scenarios by checking out the following demo projects:
+To learn how to use Plotters in different scenarios, check out the following demo projects:
- WebAssembly + Plotters: [plotters-wasm-demo](https://github.com/plotters-rs/plotters-wasm-demo)
- minifb + Plotters: [plotters-minifb-demo](https://github.com/plotters-rs/plotters-minifb-demo)
-- GTK + Plotters: [plotters-gtk-demo](https://github.com/plotters/plotters-gtk-demo)
+- GTK + Plotters: [plotters-gtk-demo](https://github.com/plotters-rs/plotters-gtk-demo)
## Trying with Jupyter evcxr Kernel Interactively
-Plotters now supports integrate with `evcxr` and is able to interactively drawing plots in Jupyter Notebook.
+Plotters now supports integration with `evcxr` and is able to interactively draw plots in Jupyter Notebook.
The feature `evcxr` should be enabled when including Plotters to Jupyter Notebook.
The following code shows a minimal example of this.
```text
-:dep plotters = { git = "https://github.com/38/plotters", default_features = false, features = ["evcxr"] }
+:dep plotters = { version = "^0.3.5", default_features = false, features = ["evcxr", "all_series", "all_elements"] }
extern crate plotters;
use plotters::prelude::*;
let figure = evcxr_figure((640, 480), |root| {
- root.fill(&WHITE);
+ root.fill(&WHITE)?;
let mut chart = ChartBuilder::on(&root)
.caption("y=x^2", ("Arial", 50).into_font())
.margin(5)
@@ -396,7 +396,7 @@ figure
## Interactive Tutorial with Jupyter Notebook
-*This tutorial is now working in progress and isn't complete*
+*This tutorial is a work in progress and isn't complete*
Thanks to the evcxr, now we have an interactive tutorial for Plotters!
To use the interactive notebook, you must have Jupyter and evcxr installed on your computer.
@@ -406,57 +406,55 @@ After that, you should be able to start your Jupyter server locally and load the
```bash
git clone https://github.com/38/plotters-doc-data
-cd plotteres-doc-data
+cd plotters-doc-data
jupyter notebook
```
And select the notebook called `evcxr-jupyter-integration.ipynb`.
-Also, there's a static HTML version of this notebook available at the [this location](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html)
+Also, there's a static HTML version of this notebook available at [this location](https://plotters-rs.github.io/plotters-doc-data/evcxr-jupyter-integration.html)
## Plotting in Rust
-Rust is a perfect language for data visualization. Although there are many mature visualization libraries in many different languages.
-But Rust is one of the best languages fits the need.
+Rust is a perfect language for data visualization. Although there are many mature visualization libraries in many different languages, Rust is one of the best languages that fits the need.
* **Easy to use** Rust has a very good iterator system built into the standard library. With the help of iterators,
-Plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library
+plotting in Rust can be as easy as most of the high-level programming languages. The Rust based plotting library
can be very easy to use.
-* **Fast** If you need rendering a figure with trillions of data points,
-Rust is a good choice. Rust's performance allows you to combine data processing step
+* **Fast** If you need to render a figure with trillions of data points,
+Rust is a good choice. Rust's performance allows you to combine the data processing step
and rendering step into a single application. When plotting in high-level programming languages,
e.g. Javascript or Python, data points must be down-sampled before feeding into the plotting
program because of the performance considerations. Rust is fast enough to do the data processing and visualization
within a single program. You can also integrate the
-figure rendering code into your application handling a huge amount of data and visualize it in real-time.
+figure rendering code into your application to handle a huge amount of data and visualize it in real-time.
-* **WebAssembly Support** Rust is one of few the language with the best WASM support. Plotting in Rust could be
+* **WebAssembly Support** Rust is one of the languages with the best WASM support. Plotting in Rust could be
very useful for visualization on a web page and would have a huge performance improvement comparing to Javascript.
## Plotting on HTML5 canvas with WASM Backend
-Plotters currently supports backend that uses the HTML5 canvas. To use the WASM support, you can simply use
+Plotters currently supports a backend that uses the HTML5 canvas. To use WASM, you can simply use
`CanvasBackend` instead of other backend and all other API remains the same!
There's a small demo for Plotters + WASM available at [here](https://github.com/plotters-rs/plotters-wasm-demo).
To play with the deployed version, follow this [link](https://plotters-rs.github.io/wasm-demo/www/index.html).
-
## What types of figure are supported?
Plotters is not limited to any specific type of figure.
You can create your own types of figures easily with the Plotters API.
-But Plotters provides some builtin figure types for convenience.
+Plotters does provide some built-in figure types for convenience.
Currently, we support line series, point series, candlestick series, and histogram.
And the library is designed to be able to render multiple figure into a single image.
But Plotter is aimed to be a platform that is fully extendable to support any other types of figure.
-## Concepts by examples
+## Concepts by example
-### Drawing Back-ends
-Plotters can use different drawing back-ends, including SVG, BitMap, and even real-time rendering. For example, a bitmap drawing backend.
+### Drawing Backends
+Plotters can use different drawing backends, including SVG, BitMap, and even real-time rendering. For example, a bitmap drawing backend.
```rust
use plotters::prelude::*;
@@ -475,10 +473,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
### Drawing Area
Plotters uses a concept called drawing area for layout purpose.
-Plotters support multiple integrating into a single image.
+Plotters supports integrating multiple figures into a single image.
This is done by creating sub-drawing-areas.
-Besides that, the drawing area also allows the customized coordinate system, by doing so, the coordinate mapping is done by the drawing area automatically.
+Besides that, the drawing area also allows for a customized coordinate system, by doing so, the coordinate mapping is done by the drawing area automatically.
```rust
use plotters::prelude::*;
@@ -500,7 +498,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
### Elements
-In Plotters, elements are build blocks of figures. All elements are able to draw on a drawing area.
+In Plotters, elements are the building blocks of figures. All elements are able to be drawn on a drawing area.
There are different types of built-in elements, like lines, texts, circles, etc.
You can also define your own element in the application code.
@@ -528,9 +526,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
### Composable Elements
-Besides the built-in elements, elements can be composed into a logic group we called composed elements.
+Besides the built-in elements, elements can be composed into a logical group we called composed elements.
When composing new elements, the upper-left corner is given in the target coordinate, and a new pixel-based
-coordinate which has the upper-left corner defined as `(0,0)` is used for further element composition purpose.
+coordinate which has the upper-left corner defined as `(0,0)` is used for further element composition.
For example, we can have an element which includes a dot and its coordinate.
@@ -571,7 +569,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
### Chart Context
-In order to draw a chart, Plotters need a data object built on top of the drawing area called `ChartContext`.
+In order to draw a chart, Plotters needs a data object built on top of the drawing area called `ChartContext`.
The chart context defines even higher level constructs compare to the drawing area.
For example, you can define the label areas, meshes, and put a data series onto the drawing area with the help
of the chart context object.
@@ -582,7 +580,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let root = BitMapBackend::new("plotters-doc-data/5.png", (640, 480)).into_drawing_area();
root.fill(&WHITE);
let root = root.margin(10, 10, 10, 10);
- // After this point, we should be able to draw construct a chart context
+ // After this point, we should be able to construct a chart context
let mut chart = ChartBuilder::on(&root)
// Set the caption of the chart
.caption("This is our first plot", ("sans-serif", 40).into_font())
@@ -629,14 +627,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
### Development Version
-Find the latest development version of Plotters on [GitHub](https://github.com/38/plotters.git).
+Find the latest development version of Plotters on [GitHub](https://github.com/plotters-rs/plotters.git).
Clone the repository and learn more about the Plotters API and ways to contribute. Your help is needed!
If you want to add the development version of Plotters to your project, add the following to your `Cargo.toml`:
```toml
[dependencies]
-plotters = { git = "https://github.com/38/plotters.git" }
+plotters = { git = "https://github.com/plotters-rs/plotters.git" }
```
### Reducing Depending Libraries && Turning Off Backends
@@ -650,7 +648,7 @@ For example, the following dependency description would avoid compiling with bit
```toml
[dependencies]
-plotters = { git = "https://github.com/38/plotters.git", default_features = false, features = ["svg"] }
+plotters = { git = "https://github.com/plotters-rs/plotters.git", default_features = false, features = ["svg"] }
```
The library also allows consumers to make use of the [`Palette`](https://crates.io/crates/palette/) crate's color types by default.
@@ -663,21 +661,50 @@ Use `default_features = false` to disable those default enabled features,
and then you should be able to cherry-pick what features you want to include into `Plotters` crate.
By doing so, you can minimize the number of dependencies down to only `itertools` and compile time is less than 6s.
-The following list is a complete list of features that can be opt in and out.
+The following list is a complete list of features that can be opted in or out.
- Tier 1 drawing backends
| Name | Description | Additional Dependency |Default?|
|---------|--------------|--------|------------|
-| bitmap\_encoder | Allow `BitMapBackend` save the result to bitmap files | image, rusttype, font-kit | Yes |
+| bitmap\_encoder | Allow `BitMapBackend` to save the result to bitmap files | image, rusttype, font-kit | Yes |
| svg\_backend | Enable `SVGBackend` Support | None | Yes |
| bitmap\_gif| Opt-in GIF animation Rendering support for `BitMapBackend`, implies `bitmap` enabled | gif | Yes |
- Font manipulation features
-| Name | Description | Additional Dependency |Default?|
-|---------|--------------|--------|------------|
-| ttf | Allows TrueType font support | rusttype, font-kit | Yes |
+| Name | Description | Additional Dependency | Default? |
+|----------|------------------------------------------|-----------------------|----------|
+| ttf | Allows TrueType font support | font-kit | Yes |
+| ab_glyph | Skips loading system fonts, unlike `ttf` | ab_glyph | No |
+
+`ab_glyph` supports TrueType and OpenType fonts, but does not attempt to
+load fonts provided by the system on which it is running.
+It is pure Rust, and easier to cross compile.
+To use this, you *must* call `plotters::style::register_font` before
+using any `plotters` functions which require the ability to render text.
+This function only exists when the `ab_glyph` feature is enabled.
+```rust,ignore
+/// Register a font in the fonts table.
+///
+/// The `name` parameter gives the name this font shall be referred to
+/// in the other APIs, like `"sans-serif"`.
+///
+/// Unprovided font styles for a given name will fallback to `FontStyle::Normal`
+/// if that is available for that name, when other functions lookup fonts which
+/// are registered with this function.
+///
+/// The `bytes` parameter should be the complete contents
+/// of an OpenType font file, like:
+/// ```ignore
+/// include_bytes!("FiraGO-Regular.otf")
+/// ```
+pub fn register_font(
+ name: &str,
+ style: FontStyle,
+ bytes: &'static [u8],
+) -> Result<(), InvalidFont>
+```
- Coordinate features
@@ -715,7 +742,7 @@ The following list is a complete list of features that can be opt in and out.
* How to draw text/circle/point/rectangle/... on the top of chart ?
- As you may realized, Plotters is a drawing library rather than a traditional data plotting library,
+ As you may have realized, Plotters is a drawing library rather than a traditional data plotting library,
you have the freedom to draw anything you want on the drawing area.
Use `DrawingArea::draw` to draw any element on the drawing area.
@@ -729,10 +756,10 @@ The following list is a complete list of features that can be opt in and out.
- [HTML5 Canvas Backend](https://github.com/plotters-rs/plotters-canvas.git)
- [GTK/Cairo Backend](https://github.com/plotters-rs/plotters-cairo.git)
-* How to check if a backend writes file successfully ?
+* How to check if a backend writes to a file successfully ?
- The behavior of Plotters backend is consistent with standard library.
- When the backend instance is being dropped, [`crate::drawing::DrawingArea::present()`] or `Backend::present()` is called automatically
+ The behavior of Plotters backend is consistent with the standard library.
+ When the backend instance is dropped, [`crate::drawing::DrawingArea::present()`] or `Backend::present()` is called automatically
whenever is needed. When the `present()` method is called from `drop`, any error will be silently ignored.
In the case that error handling is important, you need manually call the `present()` method before the backend gets dropped.
@@ -825,6 +852,9 @@ pub mod prelude {
#[cfg(feature = "full_palette")]
pub use crate::style::full_palette;
+ #[cfg(feature = "colormaps")]
+ pub use crate::style::colors::colormaps::*;
+
pub use crate::style::{
AsRelative, Color, FontDesc, FontFamily, FontStyle, FontTransform, HSLColor, IntoFont,
IntoTextStyle, Palette, Palette100, Palette99, Palette9999, PaletteColor, RGBAColor,
diff --git a/src/series/line_series.rs b/src/series/line_series.rs
index 2d0cf98..448d029 100644
--- a/src/series/line_series.rs
+++ b/src/series/line_series.rs
@@ -45,8 +45,7 @@ impl<DB: DrawingBackend, Coord: Clone + 'static> Iterator for LineSeries<DB, Coo
let idx = self.point_idx;
self.point_idx += 1;
return Some(
- Circle::new(self.data[idx].clone(), self.point_size, self.style)
- .into_dyn(),
+ Circle::new(self.data[idx].clone(), self.point_size, self.style).into_dyn(),
);
}
let mut data = vec![];
diff --git a/src/style/colors/colormaps.rs b/src/style/colors/colormaps.rs
new file mode 100644
index 0000000..50430db
--- /dev/null
+++ b/src/style/colors/colormaps.rs
@@ -0,0 +1,311 @@
+use crate::style::{HSLColor, RGBAColor, RGBColor};
+
+use num_traits::{Float, FromPrimitive, ToPrimitive};
+
+/// Converts scalar values to colors.
+pub trait ColorMap<ColorType: crate::prelude::Color, FloatType = f32>
+where
+ FloatType: Float,
+{
+ /// Takes a scalar value 0.0 <= h <= 1.0 and returns the corresponding color.
+ /// Typically color-scales are named according to which color-type they return.
+ /// To use upper and lower bounds with ths function see [get_color_normalized](ColorMap::get_color_normalized).
+ fn get_color(&self, h: FloatType) -> ColorType {
+ self.get_color_normalized(h, FloatType::zero(), FloatType::one())
+ }
+
+ /// A slight abstraction over [get_color](ColorMap::get_color) function where lower and upper bound can be specified.
+ fn get_color_normalized(&self, h: FloatType, min: FloatType, max: FloatType) -> ColorType;
+}
+
+/// This struct is used to dynamically construct colormaps by giving it a slice of colors.
+/// It can then be used when being intantiated, but not with associated functions.
+/// ```
+/// use plotters::prelude::{BLACK,BLUE,WHITE,DerivedColorMap,ColorMap};
+///
+/// let derived_colormap = DerivedColorMap::new(
+/// &[BLACK,
+/// BLUE,
+/// WHITE]
+/// );
+///
+/// assert_eq!(derived_colormap.get_color(0.0), BLACK);
+/// assert_eq!(derived_colormap.get_color(0.5), BLUE);
+/// assert_eq!(derived_colormap.get_color(1.0), WHITE);
+/// ```
+pub struct DerivedColorMap<ColorType> {
+ colors: Vec<ColorType>,
+}
+
+impl<ColorType: crate::style::Color + Clone> DerivedColorMap<ColorType> {
+ /// This function lets the user define a new colormap by simply specifying colors in the correct order.
+ /// For calculation of the color values, the colors will be spaced evenly apart.
+ pub fn new(colors: &[ColorType]) -> Self {
+ DerivedColorMap {
+ colors: colors.to_vec(),
+ }
+ }
+}
+
+macro_rules! calculate_new_color_value(
+ ($relative_difference:expr, $colors:expr, $index_upper:expr, $index_lower:expr, RGBColor) => {
+ RGBColor(
+ // These equations are a very complicated way of writing a simple linear extrapolation with lots of casting between numerical values
+ // In principle every cast should be safe which is why we choose to unwrap
+ // (1.0 - r) * color_value_1 + r * color_value_2
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].0).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].0).unwrap()).round().to_u8().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].1).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].1).unwrap()).round().to_u8().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].2).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].2).unwrap()).round().to_u8().unwrap()
+ )
+ };
+ ($relative_difference:expr, $colors:expr, $index_upper:expr, $index_lower:expr, RGBAColor) => {
+ RGBAColor(
+ // These equations are a very complicated way of writing a simple linear extrapolation with lots of casting between numerical values
+ // In principle every cast should be safe which is why we choose to unwrap
+ // (1.0 - r) * color_value_1 + r * color_value_2
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].0).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].0).unwrap()).round().to_u8().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].1).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].1).unwrap()).round().to_u8().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_u8($colors[$index_upper].2).unwrap() + $relative_difference * FloatType::from_u8($colors[$index_lower].2).unwrap()).round().to_u8().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_f64($colors[$index_upper].3).unwrap() + $relative_difference * FloatType::from_f64($colors[$index_lower].3).unwrap()).to_f64().unwrap()
+ )
+ };
+ ($relative_difference:expr, $colors:expr, $index_upper:expr, $index_lower:expr, HSLColor) => {
+ HSLColor(
+ // These equations are a very complicated way of writing a simple linear extrapolation with lots of casting between numerical values
+ // In principle every cast should be safe which is why we choose to unwrap
+ // (1.0 - r) * color_value_1 + r * color_value_2
+ ((FloatType::one() - $relative_difference) * FloatType::from_f64($colors[$index_upper].0).unwrap() + $relative_difference * FloatType::from_f64($colors[$index_lower].0).unwrap()).to_f64().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_f64($colors[$index_upper].1).unwrap() + $relative_difference * FloatType::from_f64($colors[$index_lower].1).unwrap()).to_f64().unwrap(),
+ ((FloatType::one() - $relative_difference) * FloatType::from_f64($colors[$index_upper].2).unwrap() + $relative_difference * FloatType::from_f64($colors[$index_lower].2).unwrap()).to_f64().unwrap(),
+ )
+ };
+);
+
+fn calculate_relative_difference_index_lower_upper<
+ FloatType: Float + FromPrimitive + ToPrimitive,
+>(
+ h: FloatType,
+ min: FloatType,
+ max: FloatType,
+ n_colors: usize,
+) -> (FloatType, usize, usize) {
+ // Ensure that we do have a value in bounds
+ let h = num_traits::clamp(h, min, max);
+ // Next calculate a normalized value between 0.0 and 1.0
+ let t = (h - min) / (max - min);
+ let approximate_index =
+ t * (FloatType::from_usize(n_colors).unwrap() - FloatType::one()).max(FloatType::zero());
+ // Calculate which index are the two most nearest of the supplied value
+ let index_lower = approximate_index.floor().to_usize().unwrap();
+ let index_upper = approximate_index.ceil().to_usize().unwrap();
+ // Calculate the relative difference, ie. is the actual value more towards the color of index_upper or index_lower?
+ let relative_difference = approximate_index.ceil() - approximate_index;
+ (relative_difference, index_lower, index_upper)
+}
+
+macro_rules! implement_color_scale_for_derived_color_map{
+ ($($color_type:ident),+) => {
+ $(
+ impl<FloatType: Float + FromPrimitive + ToPrimitive> ColorMap<$color_type, FloatType> for DerivedColorMap<$color_type> {
+ fn get_color_normalized(&self, h: FloatType, min: FloatType, max: FloatType) -> $color_type {
+ let (
+ relative_difference,
+ index_lower,
+ index_upper
+ ) = calculate_relative_difference_index_lower_upper(
+ h,
+ min,
+ max,
+ self.colors.len()
+ );
+ // Interpolate the final color linearly
+ calculate_new_color_value!(
+ relative_difference,
+ self.colors,
+ index_upper,
+ index_lower,
+ $color_type
+ )
+ }
+ }
+ )+
+ }
+}
+
+implement_color_scale_for_derived_color_map! {RGBAColor, RGBColor, HSLColor}
+
+macro_rules! count {
+ () => (0usize);
+ ($x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
+}
+
+macro_rules! define_colors_from_list_of_values_or_directly{
+ ($color_type:ident, $(($($color_value:expr),+)),+) => {
+ [$($color_type($($color_value),+)),+]
+ };
+ ($($color_complete:tt),+) => {
+ [$($color_complete),+]
+ };
+}
+
+macro_rules! implement_linear_interpolation_color_map {
+ ($color_scale_name:ident, $color_type:ident) => {
+ impl<FloatType: std::fmt::Debug + Float + FromPrimitive + ToPrimitive>
+ ColorMap<$color_type, FloatType> for $color_scale_name
+ {
+ fn get_color_normalized(
+ &self,
+ h: FloatType,
+ min: FloatType,
+ max: FloatType,
+ ) -> $color_type {
+ let (
+ relative_difference,
+ index_lower,
+ index_upper
+ ) = calculate_relative_difference_index_lower_upper(
+ h,
+ min,
+ max,
+ Self::COLORS.len()
+ );
+ // Interpolate the final color linearly
+ calculate_new_color_value!(
+ relative_difference,
+ Self::COLORS,
+ index_upper,
+ index_lower,
+ $color_type
+ )
+ }
+ }
+
+ impl $color_scale_name {
+ #[doc = "Get color value from `"]
+ #[doc = stringify!($color_scale_name)]
+ #[doc = "` by supplying a parameter 0.0 <= h <= 1.0"]
+ pub fn get_color<FloatType: std::fmt::Debug + Float + FromPrimitive + ToPrimitive>(
+ h: FloatType,
+ ) -> $color_type {
+ let color_scale = $color_scale_name {};
+ color_scale.get_color(h)
+ }
+
+ #[doc = "Get color value from `"]
+ #[doc = stringify!($color_scale_name)]
+ #[doc = "` by supplying lower and upper bounds min, max and a parameter h where min <= h <= max"]
+ pub fn get_color_normalized<
+ FloatType: std::fmt::Debug + Float + FromPrimitive + ToPrimitive,
+ >(
+ h: FloatType,
+ min: FloatType,
+ max: FloatType,
+ ) -> $color_type {
+ let color_scale = $color_scale_name {};
+ color_scale.get_color_normalized(h, min, max)
+ }
+ }
+ };
+}
+
+#[macro_export]
+/// Macro to create a new colormap with evenly spaced colors at compile-time.
+macro_rules! define_linear_interpolation_color_map{
+ ($color_scale_name:ident, $color_type:ident, $doc:expr, $(($($color_value:expr),+)),*) => {
+ #[doc = $doc]
+ pub struct $color_scale_name {}
+
+ impl $color_scale_name {
+ // const COLORS: [$color_type; $number_colors] = [$($color_type($($color_value),+)),+];
+ // const COLORS: [$color_type; count!($(($($color_value:expr),+))*)] = [$($color_type($($color_value),+)),+];
+ const COLORS: [$color_type; count!($(($($color_value:expr),+))*)] = define_colors_from_list_of_values_or_directly!{$color_type, $(($($color_value),+)),*};
+ }
+
+ implement_linear_interpolation_color_map!{$color_scale_name, $color_type}
+ };
+ ($color_scale_name:ident, $color_type:ident, $doc:expr, $($color_complete:tt),+) => {
+ #[doc = $doc]
+ pub struct $color_scale_name {}
+
+ impl $color_scale_name {
+ const COLORS: [$color_type; count!($($color_complete)*)] = define_colors_from_list_of_values_or_directly!{$($color_complete),+};
+ }
+
+ implement_linear_interpolation_color_map!{$color_scale_name, $color_type}
+ }
+}
+
+define_linear_interpolation_color_map! {
+ ViridisRGBA,
+ RGBAColor,
+ "A colormap optimized for visually impaired people (RGBA format).
+ It is currently the default colormap also used by [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html).
+ Read more in this [paper](https://doi.org/10.1371/journal.pone.0199239)",
+ ( 68, 1, 84, 1.0),
+ ( 70, 50, 127, 1.0),
+ ( 54, 92, 141, 1.0),
+ ( 39, 127, 143, 1.0),
+ ( 31, 162, 136, 1.0),
+ ( 74, 194, 110, 1.0),
+ (160, 219, 57, 1.0),
+ (254, 232, 37, 1.0)
+}
+
+define_linear_interpolation_color_map! {
+ ViridisRGB,
+ RGBColor,
+ "A colormap optimized for visually impaired people (RGB Format).
+ It is currently the default colormap also used by [matplotlib](https://matplotlib.org/stable/tutorials/colors/colormaps.html).
+ Read more in this [paper](https://doi.org/10.1371/journal.pone.0199239)",
+ ( 68, 1, 84),
+ ( 70, 50, 127),
+ ( 54, 92, 141),
+ ( 39, 127, 143),
+ ( 31, 162, 136),
+ ( 74, 194, 110),
+ (160, 219, 57),
+ (254, 232, 37)
+}
+
+define_linear_interpolation_color_map! {
+ BlackWhite,
+ RGBColor,
+ "Simple chromatic colormap from black to white.",
+ ( 0, 0, 0),
+ (255, 255, 255)
+}
+
+define_linear_interpolation_color_map! {
+ MandelbrotHSL,
+ HSLColor,
+ "Colormap created to replace the one used in the mandelbrot example.",
+ (0.0, 1.0, 0.5),
+ (1.0, 1.0, 0.5)
+}
+
+define_linear_interpolation_color_map! {
+ VulcanoHSL,
+ HSLColor,
+ "A vulcanic colormap that display red/orange and black colors",
+ (2.0/3.0, 1.0, 0.7),
+ ( 0.0, 1.0, 0.7)
+}
+
+use super::full_palette::*;
+define_linear_interpolation_color_map! {
+ Bone,
+ RGBColor,
+ "Dark colormap going from black over blue to white.",
+ BLACK,
+ BLUE,
+ WHITE
+}
+
+define_linear_interpolation_color_map! {
+ Copper,
+ RGBColor,
+ "Friendly black to brown colormap.",
+ BLACK,
+ BROWN,
+ ORANGE
+}
diff --git a/src/style/colors/mod.rs b/src/style/colors/mod.rs
index 34448ba..8aa09a7 100644
--- a/src/style/colors/mod.rs
+++ b/src/style/colors/mod.rs
@@ -1,8 +1,9 @@
//! Basic predefined colors.
use super::{RGBAColor, RGBColor};
-// Macro for allowing dynamic creation of doc attributes.
// Taken from https://stackoverflow.com/questions/60905060/prevent-line-break-in-doc-test
+/// Macro for allowing dynamic creation of doc attributes.
+#[macro_export]
macro_rules! doc {
{
$(#[$m:meta])*
@@ -55,5 +56,10 @@ define_color!(CYAN, 0, 255, 255, "Cyan");
define_color!(MAGENTA, 255, 0, 255, "Magenta");
define_color!(TRANSPARENT, 0, 0, 0, 0.0, "Transparent");
+#[cfg(feature = "colormaps")]
+/// Colormaps can be used to simply go from a scalar value to a color value which will be more/less
+/// intense corresponding to the value of the supplied scalar.
+/// These colormaps can also be defined by the user and be used with lower and upper bounds.
+pub mod colormaps;
#[cfg(feature = "full_palette")]
pub mod full_palette;
diff --git a/src/style/font/ab_glyph.rs b/src/style/font/ab_glyph.rs
new file mode 100644
index 0000000..42b4334
--- /dev/null
+++ b/src/style/font/ab_glyph.rs
@@ -0,0 +1,160 @@
+use super::{FontData, FontFamily, FontStyle, LayoutBox};
+use ab_glyph::{Font, FontRef, ScaleFont};
+use core::fmt::{self, Display};
+use once_cell::sync::Lazy;
+use std::collections::HashMap;
+use std::error::Error;
+use std::sync::RwLock;
+
+struct FontMap {
+ map: HashMap<String, FontRef<'static>>,
+}
+impl FontMap {
+ fn new() -> Self {
+ Self {
+ map: HashMap::with_capacity(4),
+ }
+ }
+ fn insert(&mut self, style: FontStyle, font: FontRef<'static>) -> Option<FontRef<'static>> {
+ self.map.insert(style.as_str().to_string(), font)
+ }
+ // fn get(&self, style: FontStyle) -> Option<&FontRef<'static>> {
+ // self.map.get(style.as_str())
+ // }
+ fn get_fallback(&self, style: FontStyle) -> Option<&FontRef<'static>> {
+ self.map
+ .get(style.as_str())
+ .or_else(|| self.map.get(FontStyle::Normal.as_str()))
+ }
+}
+
+static FONTS: Lazy<RwLock<HashMap<String, FontMap>>> = Lazy::new(|| RwLock::new(HashMap::new()));
+pub struct InvalidFont {
+ _priv: (),
+}
+
+// Note for future contributors: There is nothing fundamental about the static reference requirement here.
+// It would be reasonably easy to add a function which accepts an owned buffer,
+// or even a reference counted buffer, instead.
+/// Register a font in the fonts table.
+///
+/// The `name` parameter gives the name this font shall be referred to
+/// in the other APIs, like `"sans-serif"`.
+///
+/// Unprovided font styles for a given name will fallback to `FontStyle::Normal`
+/// if that is available for that name, when other functions lookup fonts which
+/// are registered with this function.
+///
+/// The `bytes` parameter should be the complete contents
+/// of an OpenType font file, like:
+/// ```ignore
+/// include_bytes!("FiraGO-Regular.otf")
+/// ```
+pub fn register_font(
+ name: &str,
+ style: FontStyle,
+ bytes: &'static [u8],
+) -> Result<(), InvalidFont> {
+ let font = FontRef::try_from_slice(bytes).map_err(|_| InvalidFont { _priv: () })?;
+ let mut lock = FONTS.write().unwrap();
+ lock.entry(name.to_string())
+ .or_insert_with(FontMap::new)
+ .insert(style, font);
+ Ok(())
+}
+
+#[derive(Clone)]
+pub struct FontDataInternal {
+ font_ref: FontRef<'static>,
+}
+
+#[derive(Debug, Clone)]
+pub enum FontError {
+ /// No idea what the problem is
+ Unknown,
+ /// No font data available for the requested family and style.
+ FontUnavailable,
+}
+impl Display for FontError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ // Since it makes literally no difference to how we'd format
+ // this, just delegate to the derived Debug formatter.
+ write!(f, "{:?}", self)
+ }
+}
+impl Error for FontError {}
+
+impl FontData for FontDataInternal {
+ // TODO: can we rename this to `Error`?
+ type ErrorType = FontError;
+ fn new(family: FontFamily<'_>, style: FontStyle) -> Result<Self, Self::ErrorType> {
+ Ok(Self {
+ font_ref: FONTS
+ .read()
+ .unwrap()
+ .get(family.as_str())
+ .and_then(|fam| fam.get_fallback(style))
+ .ok_or(FontError::FontUnavailable)?
+ .clone(),
+ })
+ }
+ // TODO: ngl, it makes no sense that this uses the same error type as `new`
+ fn estimate_layout(&self, size: f64, text: &str) -> Result<LayoutBox, Self::ErrorType> {
+ let pixel_per_em = size / 1.24;
+ // let units_per_em = self.font_ref.units_per_em().unwrap();
+ let font = self.font_ref.as_scaled(size as f32);
+
+ let mut x_pixels = 0f32;
+
+ let mut prev = None;
+ for c in text.chars() {
+ let glyph_id = font.glyph_id(c);
+ let size = font.h_advance(glyph_id);
+ x_pixels += size;
+ if let Some(pc) = prev {
+ x_pixels += font.kern(pc, glyph_id);
+ }
+ prev = Some(glyph_id);
+ }
+
+ Ok(((0, 0), (x_pixels as i32, pixel_per_em as i32)))
+ }
+ fn draw<E, DrawFunc: FnMut(i32, i32, f32) -> Result<(), E>>(
+ &self,
+ pos: (i32, i32),
+ size: f64,
+ text: &str,
+ mut draw: DrawFunc,
+ ) -> Result<Result<(), E>, Self::ErrorType> {
+ let font = self.font_ref.as_scaled(size as f32);
+ let mut draw = |x: i32, y: i32, c| {
+ let (base_x, base_y) = pos;
+ draw(base_x + x, base_y + y, c)
+ };
+ let mut x_shift = 0f32;
+ let mut prev = None;
+ for c in text.chars() {
+ if let Some(pc) = prev {
+ x_shift += font.kern(font.glyph_id(pc), font.glyph_id(c));
+ }
+ prev = Some(c);
+ let glyph = font.scaled_glyph(c);
+ if let Some(q) = font.outline_glyph(glyph) {
+ let rect = q.px_bounds();
+ let y_shift = ((size as f32) / 2.0 + rect.min.y) as i32;
+ let x_shift = x_shift as i32;
+ let mut buf = vec![];
+ q.draw(|x, y, c| buf.push((x, y, c)));
+ for (x, y, c) in buf {
+ draw(x as i32 + x_shift, y as i32 + y_shift, c).map_err(|_e| {
+ // Note: If ever `plotters` adds a tracing or logging crate,
+ // this would be a good place to use it.
+ FontError::Unknown
+ })?;
+ }
+ }
+ x_shift += font.h_advance(font.glyph_id(c));
+ }
+ Ok(Ok(()))
+ }
+}
diff --git a/src/style/font/mod.rs b/src/style/font/mod.rs
index 305978f..d80ee28 100644
--- a/src/style/font/mod.rs
+++ b/src/style/font/mod.rs
@@ -18,13 +18,35 @@ mod ttf;
use ttf::FontDataInternal;
#[cfg(all(
- not(all(target_arch = "wasm32", not(target_os = "wasi"))),
+ not(target_arch = "wasm32"),
+ not(target_os = "wasi"),
+ feature = "ab_glyph"
+))]
+mod ab_glyph;
+#[cfg(all(
+ not(target_arch = "wasm32"),
+ not(target_os = "wasi"),
+ feature = "ab_glyph"
+))]
+pub use self::ab_glyph::register_font;
+#[cfg(all(
+ not(target_arch = "wasm32"),
+ not(target_os = "wasi"),
+ feature = "ab_glyph",
not(feature = "ttf")
))]
+use self::ab_glyph::FontDataInternal;
+
+#[cfg(all(
+ not(all(target_arch = "wasm32", not(target_os = "wasi"))),
+ not(feature = "ttf"),
+ not(feature = "ab_glyph")
+))]
mod naive;
#[cfg(all(
not(all(target_arch = "wasm32", not(target_os = "wasi"))),
- not(feature = "ttf")
+ not(feature = "ttf"),
+ not(feature = "ab_glyph")
))]
use naive::FontDataInternal;
diff --git a/src/style/font/ttf.rs b/src/style/font/ttf.rs
index e6feadc..345aae4 100644
--- a/src/style/font/ttf.rs
+++ b/src/style/font/ttf.rs
@@ -82,9 +82,7 @@ impl FontExt {
_ => unreachable!(),
};
let face = unsafe {
- std::mem::transmute::<_, Option<Face<'static>>>(
- ttf_parser::Face::from_slice(data, idx).ok(),
- )
+ std::mem::transmute::<_, Option<Face<'static>>>(ttf_parser::Face::parse(data, idx).ok())
};
Self { inner: font, face }
}
diff --git a/src/style/mod.rs b/src/style/mod.rs
index 7d7c9ac..4daa0a8 100644
--- a/src/style/mod.rs
+++ b/src/style/mod.rs
@@ -17,9 +17,12 @@ pub use colors::{BLACK, BLUE, CYAN, GREEN, MAGENTA, RED, TRANSPARENT, WHITE, YEL
#[cfg(feature = "full_palette")]
pub use colors::full_palette;
+#[cfg(all(not(target_arch = "wasm32"), feature = "ab_glyph"))]
+pub use font::register_font;
pub use font::{
FontDesc, FontError, FontFamily, FontResult, FontStyle, FontTransform, IntoFont, LayoutBox,
};
+
pub use shape::ShapeStyle;
pub use size::{AsRelative, RelativeSize, SizeDesc};
pub use text::text_anchor;