()
| 34 | } |
| 35 | |
| 36 | fn new_scatter() -> PlotWidget { |
| 37 | // Generate 5 million points from 2D Gaussian |
| 38 | let mut rng = rand::rng(); |
| 39 | let normal = Normal::new(0.0f64, 1.0f64).unwrap(); |
| 40 | let positions = (0..5_000_000) |
| 41 | .map(|_| [normal.sample(&mut rng), normal.sample(&mut rng)]) |
| 42 | .collect::<Vec<[f64; 2]>>(); |
| 43 | |
| 44 | let series = Series::markers_only(positions, MarkerStyle::circle(1.0)) |
| 45 | .with_label("2d Gaussian scatter - 5M points") |
| 46 | .with_color(Color::from_rgb(0.2, 0.6, 1.0)); |
| 47 | |
| 48 | PlotWidgetBuilder::new() |
| 49 | .with_hover_highlight_provider(|context, point| { |
| 50 | point.color = Color::from_rgb(1.0, 0.5, 0.2); |
| 51 | point.resize_marker(1.5); |
| 52 | Some(format!( |
| 53 | "point: {}\nx: {:.3}, y: {:.3}", |
| 54 | context.point_index, point.x, point.y |
| 55 | )) |
| 56 | }) |
| 57 | .with_pick_highlight_provider(|context, point| { |
| 58 | point.color = Color::from_rgb(1.0, 0.0, 0.0); |
| 59 | point.mask_padding = None; |
| 60 | point.resize_marker(3.0); |
| 61 | Some(format!( |
| 62 | "point: {}\nx: {:.3}, y: {:.3}", |
| 63 | context.point_index, point.x, point.y |
| 64 | )) |
| 65 | }) |
| 66 | .add_series(series.clone()) |
| 67 | .build() |
| 68 | .unwrap() |
| 69 | } |
nothing calls this directly
no test coverage detected