Skip to content

Commit 24d9b81

Browse files
authored
Merge pull request #16 from alceal:feature/line-width-and-optional-shape-for-lineplot-and-timeseriesplot
feat: Add optional shape and add line width for line and time series plots
2 parents a6a06d8 + 2d77fca commit 24d9b81

File tree

8 files changed

+110
-23
lines changed

8 files changed

+110
-23
lines changed

src/aesthetics/line.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub(crate) trait Line {
4141
fn set_line_type(
4242
line: &LinePlotly,
4343
line_types: &Option<Vec<LineType>>,
44+
width: Option<f64>,
4445
index: usize,
4546
) -> LinePlotly {
4647
let mut updated_line = line.clone();
@@ -52,6 +53,10 @@ pub(crate) trait Line {
5253
}
5354
}
5455

56+
if let Some(width) = width {
57+
updated_line = updated_line.width(width);
58+
}
59+
5560
updated_line
5661
}
5762

src/traces/barplot.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ impl BarPlot {
4949
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
5050
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
5151
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
52+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
5253
///
5354
/// # Returns
5455
///
@@ -170,9 +171,11 @@ impl BarPlot {
170171

171172
let opacity = None;
172173
let size = None;
174+
let with_shape = None;
173175
let shape = None;
174176
let shapes = None;
175177
let line_types = None;
178+
let line_width = None;
176179

177180
let traces = Self::create_traces(
178181
data,
@@ -189,9 +192,11 @@ impl BarPlot {
189192
size,
190193
color,
191194
colors,
195+
with_shape,
192196
shape,
193197
shapes,
194198
line_types,
199+
line_width,
195200
);
196201

197202
Self { traces, layout }
@@ -214,6 +219,7 @@ impl Trace for BarPlot {
214219
#[allow(unused_variables)] box_points: Option<bool>,
215220
#[allow(unused_variables)] point_offset: Option<f64>,
216221
#[allow(unused_variables)] jitter: Option<f64>,
222+
#[allow(unused_variables)] with_shape: Option<bool>,
217223
marker: Marker,
218224
#[allow(unused_variables)] line: LinePlotly,
219225
) -> Box<dyn TracePlotly + 'static> {
@@ -331,6 +337,7 @@ impl VerticalBarPlot {
331337
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
332338
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
333339
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
340+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
334341
///
335342
/// # Returns
336343
///
@@ -416,9 +423,11 @@ impl VerticalBarPlot {
416423

417424
let opacity = None;
418425
let size = None;
426+
let with_shape = None;
419427
let shape = None;
420428
let shapes = None;
421429
let line_types = None;
430+
let line_width = None;
422431

423432
let traces = Self::create_traces(
424433
data,
@@ -435,9 +444,11 @@ impl VerticalBarPlot {
435444
size,
436445
color,
437446
colors,
447+
with_shape,
438448
shape,
439449
shapes,
440450
line_types,
451+
line_width,
441452
);
442453

443454
Self { traces, layout }
@@ -460,6 +471,7 @@ impl Trace for VerticalBarPlot {
460471
#[allow(unused_variables)] box_points: Option<bool>,
461472
#[allow(unused_variables)] point_offset: Option<f64>,
462473
#[allow(unused_variables)] jitter: Option<f64>,
474+
#[allow(unused_variables)] with_shape: Option<bool>,
463475
marker: Marker,
464476
#[allow(unused_variables)] line: LinePlotly,
465477
) -> Box<dyn TracePlotly + 'static> {
@@ -526,6 +538,7 @@ impl HorizontalBarPlot {
526538
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
527539
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
528540
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
541+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
529542
///
530543
/// # Returns
531544
///
@@ -611,9 +624,11 @@ impl HorizontalBarPlot {
611624

612625
let opacity = None;
613626
let size = None;
627+
let with_shape = None;
614628
let shape = None;
615629
let shapes = None;
616630
let line_type = None;
631+
let line_width = None;
617632

618633
let traces = Self::create_traces(
619634
data,
@@ -630,9 +645,11 @@ impl HorizontalBarPlot {
630645
size,
631646
color,
632647
colors,
648+
with_shape,
633649
shape,
634650
shapes,
635651
line_type,
652+
line_width,
636653
);
637654

638655
Self { traces, layout }
@@ -655,6 +672,7 @@ impl Trace for HorizontalBarPlot {
655672
#[allow(unused_variables)] box_points: Option<bool>,
656673
#[allow(unused_variables)] point_offset: Option<f64>,
657674
#[allow(unused_variables)] jitter: Option<f64>,
675+
#[allow(unused_variables)] with_shape: Option<bool>,
658676
marker: Marker,
659677
#[allow(unused_variables)] line: LinePlotly,
660678
) -> Box<dyn TracePlotly + 'static> {

src/traces/boxplot.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl BoxPlot {
5252
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
5353
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
5454
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
55+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
5556
///
5657
/// # Returns
5758
///
@@ -187,9 +188,11 @@ impl BoxPlot {
187188
let additional_series = None;
188189

189190
let size = None;
191+
let with_shape = None;
190192
let shape = None;
191193
let shapes = None;
192194
let line_types = None;
195+
let line_width = None;
193196

194197
let traces = Self::create_traces(
195198
data,
@@ -206,9 +209,11 @@ impl BoxPlot {
206209
size,
207210
color,
208211
colors,
212+
with_shape,
209213
shape,
210214
shapes,
211215
line_types,
216+
line_width,
212217
);
213218

214219
Self { traces, layout }
@@ -231,6 +236,7 @@ impl Trace for BoxPlot {
231236
box_points: Option<bool>,
232237
point_offset: Option<f64>,
233238
jitter: Option<f64>,
239+
#[allow(unused_variables)] with_shape: Option<bool>,
234240
marker: Marker,
235241
#[allow(unused_variables)] line: LinePlotly,
236242
) -> Box<dyn TracePlotly + 'static> {
@@ -373,6 +379,7 @@ impl VerticalBoxPlot {
373379
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
374380
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
375381
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
382+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
376383
///
377384
/// # Returns
378385
///
@@ -465,9 +472,11 @@ impl VerticalBoxPlot {
465472
let additional_series = None;
466473

467474
let size = None;
475+
let with_shape = None;
468476
let shape = None;
469477
let shapes = None;
470478
let line_types = None;
479+
let line_width = None;
471480

472481
let traces = Self::create_traces(
473482
data,
@@ -484,9 +493,11 @@ impl VerticalBoxPlot {
484493
size,
485494
color,
486495
colors,
496+
with_shape,
487497
shape,
488498
shapes,
489499
line_types,
500+
line_width,
490501
);
491502

492503
Self { traces, layout }
@@ -509,6 +520,7 @@ impl Trace for VerticalBoxPlot {
509520
box_points: Option<bool>,
510521
point_offset: Option<f64>,
511522
jitter: Option<f64>,
523+
#[allow(unused_variables)] with_shape: Option<bool>,
512524
marker: Marker,
513525
#[allow(unused_variables)] line: LinePlotly,
514526
) -> Box<dyn TracePlotly + 'static> {
@@ -585,6 +597,7 @@ impl HorizontalBoxPlot {
585597
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
586598
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
587599
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
600+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
588601
///
589602
/// # Returns
590603
///
@@ -677,9 +690,11 @@ impl HorizontalBoxPlot {
677690
let additional_series = None;
678691

679692
let size = None;
693+
let with_shape = None;
680694
let shape = None;
681695
let shapes = None;
682696
let line_type = None;
697+
let line_width = None;
683698

684699
let traces = Self::create_traces(
685700
data,
@@ -696,9 +711,11 @@ impl HorizontalBoxPlot {
696711
size,
697712
color,
698713
colors,
714+
with_shape,
699715
shape,
700716
shapes,
701717
line_type,
718+
line_width,
702719
);
703720

704721
Self { traces, layout }
@@ -721,6 +738,7 @@ impl Trace for HorizontalBoxPlot {
721738
box_points: Option<bool>,
722739
point_offset: Option<f64>,
723740
jitter: Option<f64>,
741+
#[allow(unused_variables)] with_shape: Option<bool>,
724742
marker: Marker,
725743
#[allow(unused_variables)] line: LinePlotly,
726744
) -> Box<dyn TracePlotly + 'static> {

src/traces/histogram.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl Histogram {
4141
/// * `legend_title` - An optional `Text` struct specifying the title of the legend.
4242
/// * `x_axis` - An optional reference to an `Axis` struct for customizing the x-axis.
4343
/// * `y_axis` - An optional reference to an `Axis` struct for customizing the y-axis.
44+
/// * `legend` - An optional reference to a `Legend` struct for customizing the legend of the plot (e.g., positioning, font, etc.).
4445
///
4546
/// # Returns
4647
///
@@ -128,9 +129,11 @@ impl Histogram {
128129
let additional_series = None;
129130

130131
let size = None;
132+
let with_shape = None;
131133
let shape = None;
132134
let shapes = None;
133135
let line_types = None;
136+
let line_width = None;
134137

135138
let traces = Self::create_traces(
136139
data,
@@ -147,9 +150,11 @@ impl Histogram {
147150
size,
148151
color,
149152
colors,
153+
with_shape,
150154
shape,
151155
shapes,
152156
line_types,
157+
line_width,
153158
);
154159

155160
Self { traces, layout }
@@ -172,6 +177,7 @@ impl Trace for Histogram {
172177
#[allow(unused_variables)] box_points: Option<bool>,
173178
#[allow(unused_variables)] point_offset: Option<f64>,
174179
#[allow(unused_variables)] jitter: Option<f64>,
180+
#[allow(unused_variables)] with_shape: Option<bool>,
175181
marker: Marker,
176182
#[allow(unused_variables)] line: LinePlotly,
177183
) -> Box<dyn TracePlotly + 'static> {

0 commit comments

Comments
 (0)