@@ -5,12 +5,12 @@ use super::axes3d::Axes3dStyle;
55use super :: { DualCoordChartContext , MeshStyle , SeriesAnno , SeriesLabelStyle } ;
66
77use crate :: coord:: cartesian:: { Cartesian2d , Cartesian3d , MeshLine } ;
8- use crate :: coord:: ranged3d:: { ProjectionMatrix , ProjectionMatrixBuilder } ;
98use crate :: coord:: ranged1d:: { AsRangedCoord , KeyPointHint , Ranged , ValueFormatter } ;
9+ use crate :: coord:: ranged3d:: { ProjectionMatrix , ProjectionMatrixBuilder } ;
1010use crate :: coord:: { CoordTranslate , ReverseCoordTranslate , Shift } ;
1111
1212use crate :: drawing:: { DrawingArea , DrawingAreaErrorKind } ;
13- use crate :: element:: { Drawable , PathElement , PointCollection , Polygon , Text , EmptyElement } ;
13+ use crate :: element:: { Drawable , EmptyElement , PathElement , PointCollection , Polygon , Text } ;
1414use crate :: style:: text_anchor:: { HPos , Pos , VPos } ;
1515use crate :: style:: { ShapeStyle , TextStyle } ;
1616
@@ -586,12 +586,18 @@ where
586586}
587587impl < ' a , DB , X : Ranged , Y : Ranged , Z : Ranged > ChartContext < ' a , DB , Cartesian3d < X , Y , Z > >
588588where
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+ }
595601}
596602
597603impl < ' a , DB , X : Ranged , Y : Ranged , Z : Ranged > ChartContext < ' a , DB , Cartesian3d < X , Y , Z > >
@@ -619,15 +625,26 @@ where
619625 }
620626 pub ( super ) fn draw_axis_ticks (
621627 & 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+ ) ] ,
624633 tick_size : i32 ,
625634 style : ShapeStyle ,
626- font : TextStyle
635+ font : TextStyle ,
627636 ) -> Result < ( ) , DrawingAreaErrorKind < DB :: ErrorType > > {
628637 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+ ] ) ) ;
631648 let axis_dir = ( end. 0 - begin. 0 , end. 1 - begin. 1 ) ;
632649 let ( x_range, y_range) = self . plotting_area ( ) . get_pixel_range ( ) ;
633650 let x_mid = ( x_range. start + x_range. end ) / 2 ;
@@ -648,11 +665,7 @@ where
648665 let x_score = ( x_dir. 0 * axis_dir. 0 + x_dir. 1 * axis_dir. 1 ) . abs ( ) ;
649666 let y_score = ( y_dir. 0 * axis_dir. 0 + y_dir. 1 * axis_dir. 1 ) . abs ( ) ;
650667
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 } ;
656669
657670 for ( pos, text) in labels {
658671 let logic_pos = Coord3D :: build_coord ( [ & pos[ 0 ] , & pos[ 1 ] , & pos[ 2 ] ] ) ;
@@ -668,8 +681,8 @@ where
668681 font. pos = Pos :: new ( HPos :: Center , VPos :: Top ) ;
669682 } ;
670683 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 ( ) ) ;
673686 self . plotting_area ( ) . draw ( & element) ?;
674687 }
675688 Ok ( ( ) )
@@ -679,7 +692,10 @@ where
679692 idx : usize ,
680693 panels : & [ [ [ Coord3D < X :: ValueType , Y :: ValueType , Z :: ValueType > ; 3 ] ; 2 ] ; 3 ] ,
681694 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+ > {
683699 let coord = self . plotting_area ( ) . as_coord_spec ( ) ;
684700 let x_range = coord. logic_x . range ( ) ;
685701 let y_range = coord. logic_y . range ( ) ;
@@ -808,20 +824,21 @@ where
808824 n[ ( idx + 2 ) % 3 ] = b[ ( idx + 2 ) % 3 ] ;
809825
810826 (
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+ ] ,
817833 a,
818834 b,
819835 )
820836 } ;
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 ( ) ) ) ?;
822839 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 ( ) ) ) ? ;
825842
826843 for ( kps, style) in vec ! [
827844 ( light_points, light_grid_style) ,
0 commit comments