File tree Expand file tree Collapse file tree 3 files changed +31
-7
lines changed
Expand file tree Collapse file tree 3 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ fn main() {
1212 ( 6.4 , 4.3 ) ,
1313 ( 8.5 , 3.7 ) ,
1414 ] ;
15- let s1 = Plot :: new ( data) ;
15+ let s1 = Plot :: new ( data) . point_style ( PointStyle :: new ( ) . marker ( PointMarker :: Circle ) ) ;
1616 let s2 = Plot :: new ( vec ! [ ( -1.4 , 2.5 ) , ( 7.2 , -0.3 ) ] )
1717 . point_style ( PointStyle :: new ( ) . marker ( PointMarker :: Square ) ) ;
1818
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ impl<'a> Page<'a> {
8585 */
8686 pub fn to_text ( & self ) -> Result < String > {
8787 let ( width, height) = self . dimensions ;
88- // TODO compose multiple views into a plot
88+ // TODO compose multiple views into a page
8989 let view = self . views [ 0 ] ;
9090 view. to_text ( width, height)
9191 }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ use crate::axis;
2020use crate :: repr:: ContinuousRepresentation ;
2121use crate :: style:: * ;
2222use crate :: svg_render;
23+ use crate :: text_render;
2324
2425/// Representation of any plot with points in the XY plane, visualized as points and/or with lines
2526/// in-between.
@@ -173,11 +174,34 @@ impl ContinuousRepresentation for Plot {
173174
174175 fn to_text (
175176 & self ,
176- _x_axis : & axis:: ContinuousAxis ,
177- _y_axis : & axis:: ContinuousAxis ,
178- _face_width : u32 ,
179- _face_height : u32 ,
177+ x_axis : & axis:: ContinuousAxis ,
178+ y_axis : & axis:: ContinuousAxis ,
179+ face_width : u32 ,
180+ face_height : u32 ,
180181 ) -> String {
181- "" . into ( )
182+ let face_lines = if let Some ( line_style) = & self . line_style {
183+ unimplemented ! ( "Text rendering does not yet support line plots" )
184+ } else {
185+ ( 0 ..face_height)
186+ . map ( |_| " " . repeat ( face_width as usize ) )
187+ . collect :: < Vec < String > > ( )
188+ . join ( "\n " )
189+ } ;
190+ let face_points = if let Some ( point_style) = & self . point_style {
191+ text_render:: render_face_points (
192+ & self . data ,
193+ x_axis,
194+ y_axis,
195+ face_width,
196+ face_height,
197+ & point_style,
198+ )
199+ } else {
200+ ( 0 ..face_height)
201+ . map ( |_| " " . repeat ( face_width as usize ) )
202+ . collect :: < Vec < String > > ( )
203+ . join ( "\n " )
204+ } ;
205+ text_render:: overlay ( & face_lines, & face_points, 0 , 0 )
182206 }
183207}
You can’t perform that action at this time.
0 commit comments