qlog_dancer/plots/packet_received.rs
1// Copyright (C) 2025, Cloudflare, Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright notice,
9// this list of conditions and the following disclaimer.
10//
11// * Redistributions in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27use packet_sent::draw_packet_sent_received_plot;
28
29use crate::plots::*;
30
31use crate::datastore::Datastore;
32use crate::seriesstore::SeriesStore;
33
34pub fn plot_packet_received(
35 params: &PlotParameters, filename: &str, ss: &SeriesStore, ds: &Datastore,
36 ty: &ChartOutputType,
37) {
38 let chart_config = ChartConfig {
39 title: "packet-received".into(),
40 input_filename: filename.into(),
41 clamp: params.clamp.clone(),
42 app_proto: ds.application_proto,
43 host: ds.host.clone(),
44 session_id: ds.session_id,
45 ty: ty.clone(),
46 };
47
48 chart_config.init_chart_dir();
49
50 #[cfg(not(target_arch = "wasm32"))]
51 let chart_path = chart_config.chart_filepath();
52
53 #[cfg(not(target_arch = "wasm32"))]
54 let root = make_chart_bitmap_area(
55 &chart_path,
56 params.chart_size,
57 params.colors,
58 params.chart_margin,
59 );
60
61 #[cfg(target_arch = "wasm32")]
62 let canvas_id: String = chart_config.canvas_id().unwrap_or_default();
63
64 #[cfg(target_arch = "wasm32")]
65 let root =
66 make_chart_canvas_area(&canvas_id, params.colors, params.chart_margin);
67
68 let (raw_timings, _remainder) = root.split_vertically((60).percent());
69
70 draw_packet_sent_received_plot(false, filename, params, ss, &raw_timings);
71}