Describe the bug
In the book there is an example using Utc times with just dates. This works fine.
If however you use data that is all on the same day with different times of day, all times are rendered as "00:00Z".
To Reproduce
MWE:
use plotters::prelude::*;
use chrono::{Utc, TimeZone};
fn main() {
let root_area = BitMapBackend::new("out.png", (600, 400))
.into_drawing_area();
root_area.fill(&WHITE).unwrap();
let start_date = Utc.with_ymd_and_hms(2019, 10, 1, 8, 0, 0).unwrap();
let end_date = Utc.with_ymd_and_hms(2019, 10, 1, 20, 0, 0).unwrap();
let mut ctx = ChartBuilder::on(&root_area)
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.caption("MSFT daily close price", ("sans-serif", 40))
.build_cartesian_2d(130.0..145.0, start_date..end_date )
.unwrap();
ctx.configure_mesh().draw().unwrap();
ctx.draw_series(
LineSeries::new(
(0..).zip(DATA.iter()).map(|(idx, price)| {
let day = (idx / 5) * 7 + idx % 5 + 1;
let date = Utc.with_ymd_and_hms(2019,10, 1, day, 0, 0).unwrap();
(*price, date)
}),
&BLUE,
)
).unwrap();
}
const DATA: [f64; 14] = [ 137.24, 136.37, 138.43, 137.41, 139.69, 140.41, 141.58, 139.55, 139.68, 139.10, 138.24, 135.67, 137.12, 138.12];
Describe the bug In the book there is an example using Utc times with just dates. This works fine. If however you use data that is all on the same day with different times of day, all times are rendered as "00:00Z".
To Reproduce MWE:
This is the example given in the book, but modified:
Version Information cargo.toml:
plotters = "0.3.6"