@@ -5,12 +5,12 @@ use super::axes3d::Axes3dStyle;
5
5
use super :: { DualCoordChartContext , MeshStyle , SeriesAnno , SeriesLabelStyle } ;
6
6
7
7
use crate :: coord:: cartesian:: { Cartesian2d , Cartesian3d , MeshLine } ;
8
- use crate :: coord:: ranged3d:: { ProjectionMatrix , ProjectionMatrixBuilder } ;
9
8
use crate :: coord:: ranged1d:: { AsRangedCoord , KeyPointHint , Ranged , ValueFormatter } ;
9
+ use crate :: coord:: ranged3d:: { ProjectionMatrix , ProjectionMatrixBuilder } ;
10
10
use crate :: coord:: { CoordTranslate , ReverseCoordTranslate , Shift } ;
11
11
12
12
use crate :: drawing:: { DrawingArea , DrawingAreaErrorKind } ;
13
- use crate :: element:: { Drawable , PathElement , PointCollection , Polygon , Text , EmptyElement } ;
13
+ use crate :: element:: { Drawable , EmptyElement , PathElement , PointCollection , Polygon , Text } ;
14
14
use crate :: style:: text_anchor:: { HPos , Pos , VPos } ;
15
15
use crate :: style:: { ShapeStyle , TextStyle } ;
16
16
@@ -586,12 +586,18 @@ where
586
586
}
587
587
impl < ' a , DB , X : Ranged , Y : Ranged , Z : Ranged > ChartContext < ' a , DB , Cartesian3d < X , Y , Z > >
588
588
where
589
- DB : DrawingBackend , {
590
- pub fn with_projection < P : FnOnce ( ProjectionMatrixBuilder ) -> ProjectionMatrix > ( & mut self , pf : P ) -> & mut Self {
591
- let ( actual_x, actual_y) = self . drawing_area . get_pixel_range ( ) ;
592
- self . drawing_area . as_coord_spec_mut ( ) . set_projection ( actual_x, actual_y, pf) ;
593
- self
594
- }
589
+ DB : DrawingBackend ,
590
+ {
591
+ pub fn with_projection < P : FnOnce ( ProjectionMatrixBuilder ) -> ProjectionMatrix > (
592
+ & mut self ,
593
+ pf : P ,
594
+ ) -> & mut Self {
595
+ let ( actual_x, actual_y) = self . drawing_area . get_pixel_range ( ) ;
596
+ self . drawing_area
597
+ . as_coord_spec_mut ( )
598
+ . set_projection ( actual_x, actual_y, pf) ;
599
+ self
600
+ }
595
601
}
596
602
597
603
impl < ' a , DB , X : Ranged , Y : Ranged , Z : Ranged > ChartContext < ' a , DB , Cartesian3d < X , Y , Z > >
@@ -619,15 +625,26 @@ where
619
625
}
620
626
pub ( super ) fn draw_axis_ticks (
621
627
& mut self ,
622
- axis : [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] ,
623
- labels : & [ ( [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] , String ) ] ,
628
+ axis : [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] ,
629
+ labels : & [ (
630
+ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ,
631
+ String ,
632
+ ) ] ,
624
633
tick_size : i32 ,
625
634
style : ShapeStyle ,
626
- font : TextStyle
635
+ font : TextStyle ,
627
636
) -> Result < ( ) , DrawingAreaErrorKind < DB :: ErrorType > > {
628
637
let coord = self . plotting_area ( ) . as_coord_spec ( ) ;
629
- let begin = coord. translate ( & Coord3D :: build_coord ( [ & axis[ 0 ] [ 0 ] , & axis[ 0 ] [ 1 ] , & axis[ 0 ] [ 2 ] ] ) ) ;
630
- let end = coord. translate ( & Coord3D :: build_coord ( [ & axis[ 1 ] [ 0 ] , & axis[ 1 ] [ 1 ] , & axis[ 1 ] [ 2 ] ] ) ) ;
638
+ let begin = coord. translate ( & Coord3D :: build_coord ( [
639
+ & axis[ 0 ] [ 0 ] ,
640
+ & axis[ 0 ] [ 1 ] ,
641
+ & axis[ 0 ] [ 2 ] ,
642
+ ] ) ) ;
643
+ let end = coord. translate ( & Coord3D :: build_coord ( [
644
+ & axis[ 1 ] [ 0 ] ,
645
+ & axis[ 1 ] [ 1 ] ,
646
+ & axis[ 1 ] [ 2 ] ,
647
+ ] ) ) ;
631
648
let axis_dir = ( end. 0 - begin. 0 , end. 1 - begin. 1 ) ;
632
649
let ( x_range, y_range) = self . plotting_area ( ) . get_pixel_range ( ) ;
633
650
let x_mid = ( x_range. start + x_range. end ) / 2 ;
@@ -648,11 +665,7 @@ where
648
665
let x_score = ( x_dir. 0 * axis_dir. 0 + x_dir. 1 * axis_dir. 1 ) . abs ( ) ;
649
666
let y_score = ( y_dir. 0 * axis_dir. 0 + y_dir. 1 * axis_dir. 1 ) . abs ( ) ;
650
667
651
- let dir = if x_score < y_score {
652
- x_dir
653
- } else {
654
- y_dir
655
- } ;
668
+ let dir = if x_score < y_score { x_dir } else { y_dir } ;
656
669
657
670
for ( pos, text) in labels {
658
671
let logic_pos = Coord3D :: build_coord ( [ & pos[ 0 ] , & pos[ 1 ] , & pos[ 2 ] ] ) ;
@@ -668,8 +681,8 @@ where
668
681
font. pos = Pos :: new ( HPos :: Center , VPos :: Top ) ;
669
682
} ;
670
683
let element = EmptyElement :: at ( logic_pos)
671
- + PathElement :: new ( vec ! [ ( 0 , 0 ) , dir] , style. clone ( ) )
672
- + Text :: new ( text. to_string ( ) , ( dir. 0 * 2 , dir. 1 * 2 ) , font. clone ( ) ) ;
684
+ + PathElement :: new ( vec ! [ ( 0 , 0 ) , dir] , style. clone ( ) )
685
+ + Text :: new ( text. to_string ( ) , ( dir. 0 * 2 , dir. 1 * 2 ) , font. clone ( ) ) ;
673
686
self . plotting_area ( ) . draw ( & element) ?;
674
687
}
675
688
Ok ( ( ) )
@@ -679,7 +692,10 @@ where
679
692
idx : usize ,
680
693
panels : & [ [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] ; 3 ] ,
681
694
style : ShapeStyle ,
682
- ) -> Result < [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] , DrawingAreaErrorKind < DB :: ErrorType > > {
695
+ ) -> Result <
696
+ [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] ,
697
+ DrawingAreaErrorKind < DB :: ErrorType > ,
698
+ > {
683
699
let coord = self . plotting_area ( ) . as_coord_spec ( ) ;
684
700
let x_range = coord. logic_x . range ( ) ;
685
701
let y_range = coord. logic_y . range ( ) ;
@@ -808,20 +824,21 @@ where
808
824
n[ ( idx + 2 ) % 3 ] = b[ ( idx + 2 ) % 3 ] ;
809
825
810
826
(
811
- vec ! [
812
- Coord3D :: build_coord( a) ,
813
- Coord3D :: build_coord( m) ,
814
- Coord3D :: build_coord( b) ,
815
- Coord3D :: build_coord( n) ,
816
- ] ,
827
+ vec ! [
828
+ Coord3D :: build_coord( a) ,
829
+ Coord3D :: build_coord( m) ,
830
+ Coord3D :: build_coord( b) ,
831
+ Coord3D :: build_coord( n) ,
832
+ ] ,
817
833
a,
818
834
b,
819
835
)
820
836
} ;
821
- self . plotting_area ( ) . draw ( & Polygon :: new ( panel. clone ( ) , panel_style. clone ( ) ) ) ?;
837
+ self . plotting_area ( )
838
+ . draw ( & Polygon :: new ( panel. clone ( ) , panel_style. clone ( ) ) ) ?;
822
839
panel. push ( panel[ 0 ] . clone ( ) ) ;
823
- self . plotting_area ( ) . draw ( & PathElement :: new ( panel , bold_grid_style . clone ( ) ) ) ? ;
824
-
840
+ self . plotting_area ( )
841
+ . draw ( & PathElement :: new ( panel , bold_grid_style . clone ( ) ) ) ? ;
825
842
826
843
for ( kps, style) in vec ! [
827
844
( light_points, light_grid_style) ,
0 commit comments