@@ -29,8 +29,8 @@ public function can_create_it()
2929 public function it_is_responsive ()
3030 {
3131 $ expected = [
32- 'type ' => 'line ' ,
33- 'data ' => [],
32+ 'type ' => 'line ' ,
33+ 'data ' => [],
3434 'options ' => [
3535 'responsive ' => true
3636 ]
@@ -48,10 +48,10 @@ public function it_is_responsive()
4848 public function it_is_animated ()
4949 {
5050 $ expected = [
51- 'type ' => 'line ' ,
52- 'data ' => [],
51+ 'type ' => 'line ' ,
52+ 'data ' => [],
5353 'options ' => [
54- 'responsive ' => true ,
54+ 'responsive ' => true ,
5555 'responsiveAnimationDuration ' => 10
5656 ]
5757 ];
@@ -84,8 +84,8 @@ public function it_has_basic_datasets_json()
8484 $ this ->chart ->data ($ data );
8585
8686 $ expected = json_encode ([
87- 'type ' => null ,
88- 'data ' => [
87+ 'type ' => null ,
88+ 'data ' => [
8989 'datasets ' => [
9090 (object )[
9191 'data ' => [10 , 20 , 30 ]
@@ -116,8 +116,8 @@ public function it_has_basic_data_with_labels()
116116 $ this ->chart ->data ($ data );
117117
118118 $ expected = [
119- 'type ' => null ,
120- 'data ' => [
119+ 'type ' => null ,
120+ 'data ' => [
121121 'datasets ' => [
122122 [
123123 'data ' => [10 , 20 , 30 ],
@@ -126,7 +126,7 @@ public function it_has_basic_data_with_labels()
126126 'data ' => [30 , 20 , 10 ]
127127 ]
128128 ],
129- 'labels ' => ['Red ' , 'Green ' , 'Blue ' ]
129+ 'labels ' => ['Red ' , 'Green ' , 'Blue ' ]
130130 ],
131131 'options ' => []
132132 ];
@@ -149,23 +149,65 @@ public function it_has_basic_data_with_labels_and_colors()
149149 $ this ->chart ->data ($ data );
150150
151151 $ expected = [
152- 'type ' => null ,
153- 'data ' => [
152+ 'type ' => null ,
153+ 'data ' => [
154154 'datasets ' => [
155155 [
156- 'data ' => [10 , 20 , 30 ],
156+ 'data ' => [10 , 20 , 30 ],
157157 'backgroundColor ' => ['red ' , 'green ' , 'blue ' ]
158158 ],
159159 [
160- 'data ' => [30 , 20 , 10 ],
160+ 'data ' => [30 , 20 , 10 ],
161161 'backgroundColor ' => ['red ' , 'green ' , 'blue ' ]
162162 ]
163163 ],
164- 'labels ' => ['Red ' , 'Green ' , 'Blue ' ]
164+ 'labels ' => ['Red ' , 'Green ' , 'Blue ' ]
165165 ],
166166 'options ' => []
167167 ];
168168
169169 $ this ->assertEquals ($ expected , $ this ->chart ->get ());
170170 }
171+
172+ /** @test */
173+ public function can_set_start_from_zero_using_helper ()
174+ {
175+ $ data = new Data ;
176+
177+ $ datasets = [
178+ (new Dataset )->data ([10 , 20 , 30 ])->backgroundColor (['red ' , 'green ' , 'blue ' ])
179+ ];
180+
181+ $ data ->datasets ($ datasets )->labels (['Red ' , 'Green ' , 'Blue ' ]);
182+
183+ $ this ->chart ->data ($ data );
184+
185+ $ this ->chart ->beginAtZero ();
186+
187+ $ expected = [
188+ 'type ' => null ,
189+ 'data ' => [
190+ 'datasets ' => [
191+ [
192+ 'data ' => [10 , 20 , 30 ],
193+ 'backgroundColor ' => ['red ' , 'green ' , 'blue ' ]
194+ ]
195+ ],
196+ 'labels ' => ['Red ' , 'Green ' , 'Blue ' ]
197+ ],
198+ 'options ' => [
199+ 'scales ' => [
200+ 'yAxes ' => [
201+ [
202+ 'ticks ' => [
203+ 'beginAtZero ' => true
204+ ]
205+ ]
206+ ]
207+ ]
208+ ]
209+ ];
210+
211+ $ this ->assertEquals ($ expected , $ this ->chart ->get ());
212+ }
171213}
0 commit comments