1+ /*!
2+ The `view` module provides structures for showing data in various ways.
3+ */
4+
15use std;
26use std:: f64;
37
@@ -17,6 +21,9 @@ pub struct View<'a> {
1721}
1822
1923impl < ' a > View < ' a > {
24+ /**
25+ Create an empty view
26+ */
2027 pub fn new ( ) -> View < ' a > {
2128 View {
2229 representations : vec ! [ ] ,
@@ -25,16 +32,25 @@ impl<'a> View<'a> {
2532 }
2633 }
2734
35+ /**
36+ Add a representation to the view
37+ */
2838 pub fn add ( mut self , repr : & ' a Representation ) -> Self {
2939 self . representations . push ( repr) ;
3040 self
3141 }
3242
43+ /**
44+ Set the x range for the view
45+ */
3346 pub fn x_range ( mut self , min : f64 , max : f64 ) -> Self {
3447 self . x_range = Some ( axis:: Range :: new ( min, max) ) ;
3548 self
3649 }
3750
51+ /**
52+ Set the y range for the view
53+ */
3854 pub fn y_range ( mut self , min : f64 , max : f64 ) -> Self {
3955 self . y_range = Some ( axis:: Range :: new ( min, max) ) ;
4056 self
@@ -62,6 +78,9 @@ impl<'a> View<'a> {
6278 axis:: Range :: new ( y_min, y_max)
6379 }
6480
81+ /**
82+ Create an SVG rendering of the view
83+ */
6584 pub fn to_svg ( & self , face_width : f64 , face_height : f64 ) -> svg:: node:: element:: Group {
6685 let mut view_group = svg:: node:: element:: Group :: new ( ) ;
6786
@@ -86,6 +105,9 @@ impl<'a> View<'a> {
86105 view_group
87106 }
88107
108+ /**
109+ Create a text rendering of the view
110+ */
89111 pub fn to_text ( & self , face_width : u32 , face_height : u32 ) -> String {
90112 let default_x_range = self . default_x_range ( ) ;
91113 let x_range = self . x_range . as_ref ( ) . unwrap_or ( & default_x_range) ;
0 commit comments