@@ -30,10 +30,10 @@ typedef struct
3030
3131typedef struct
3232{
33- Point * points ;
34- int64_t numPoints ;
33+ UmkaDynArray (Point ) points ;
3534 char * name ;
3635 Style style ;
36+ int64_t reserved ;
3737} Series ;
3838
3939
@@ -63,8 +63,7 @@ typedef struct
6363
6464typedef struct
6565{
66- Series * series ;
67- int64_t numSeries ;
66+ UmkaDynArray (Series ) series ;
6867 Grid grid ;
6968 Titles titles ;
7069 Legend legend ;
@@ -93,9 +92,9 @@ static Rectangle getLegendRect(const Plot *plot)
9392 if (!plot -> legend .visible )
9493 return legendRect ;
9594
96- for (int iSeries = 0 ; iSeries < plot -> numSeries ; iSeries ++ )
95+ for (int iSeries = 0 ; iSeries < plot -> series . len ; iSeries ++ )
9796 {
98- const int labelWidth = MeasureText (plot -> series [iSeries ].name , plot -> grid .fontSize );
97+ const int labelWidth = MeasureText (plot -> series . data [iSeries ].name , plot -> grid .fontSize );
9998 if (labelWidth > legendRect .width )
10099 legendRect .width = labelWidth ;
101100 }
@@ -156,12 +155,12 @@ static void resetTransform(const Plot *plot, ScreenTransform *transform)
156155 Point minPt = (Point ){ DBL_MAX , DBL_MAX };
157156 Point maxPt = (Point ){- DBL_MAX , - DBL_MAX };
158157
159- for (int iSeries = 0 ; iSeries < plot -> numSeries ; iSeries ++ )
158+ for (int iSeries = 0 ; iSeries < plot -> series . len ; iSeries ++ )
160159 {
161- Series * series = & plot -> series [iSeries ];
162- for (int iPt = 0 ; iPt < series -> numPoints ; iPt ++ )
160+ Series * series = & plot -> series . data [iSeries ];
161+ for (int iPt = 0 ; iPt < series -> points . len ; iPt ++ )
163162 {
164- const Point * pt = & series -> points [iPt ];
163+ const Point * pt = & series -> points . data [iPt ];
165164 if (pt -> x > maxPt .x ) maxPt .x = pt -> x ;
166165 if (pt -> x < minPt .x ) minPt .x = pt -> x ;
167166 if (pt -> y > maxPt .y ) maxPt .y = pt -> y ;
@@ -209,20 +208,20 @@ static void drawGraph(const Plot *plot, const ScreenTransform *transform)
209208 Rectangle clientRect = getClientRect (plot );
210209 BeginScissorMode (clientRect .x , clientRect .y , clientRect .width , clientRect .height );
211210
212- for (int iSeries = 0 ; iSeries < plot -> numSeries ; iSeries ++ )
211+ for (int iSeries = 0 ; iSeries < plot -> series . len ; iSeries ++ )
213212 {
214- Series * series = & plot -> series [iSeries ];
213+ Series * series = & plot -> series . data [iSeries ];
215214 switch (series -> style .kind )
216215 {
217216 case STYLE_LINE :
218217 {
219- if (series -> numPoints > 1 )
218+ if (series -> points . len > 1 )
220219 {
221- Vector2 prevPt = getScreenPoint (series -> points [0 ], transform );
220+ Vector2 prevPt = getScreenPoint (series -> points . data [0 ], transform );
222221
223- for (int iPt = 1 ; iPt < series -> numPoints ; iPt ++ )
222+ for (int iPt = 1 ; iPt < series -> points . len ; iPt ++ )
224223 {
225- Vector2 pt = getScreenPoint (series -> points [iPt ], transform );
224+ Vector2 pt = getScreenPoint (series -> points . data [iPt ], transform );
226225 DrawLineEx (prevPt , pt , series -> style .width , * (Color * )& series -> style .color );
227226 prevPt = pt ;
228227 }
@@ -232,9 +231,9 @@ static void drawGraph(const Plot *plot, const ScreenTransform *transform)
232231
233232 case STYLE_SCATTER :
234233 {
235- for (int iPt = 0 ; iPt < series -> numPoints ; iPt ++ )
234+ for (int iPt = 0 ; iPt < series -> points . len ; iPt ++ )
236235 {
237- Vector2 pt = getScreenPoint (series -> points [iPt ], transform );
236+ Vector2 pt = getScreenPoint (series -> points . data [iPt ], transform );
238237 DrawCircleV (pt , series -> style .width , * (Color * )& series -> style .color );
239238 }
240239 break ;
@@ -371,9 +370,9 @@ static void drawLegend(const Plot *plot, const Font *font)
371370
372371 const Rectangle legendRect = getLegendRect (plot );
373372
374- for (int iSeries = 0 ; iSeries < plot -> numSeries ; iSeries ++ )
373+ for (int iSeries = 0 ; iSeries < plot -> series . len ; iSeries ++ )
375374 {
376- Series * series = & plot -> series [iSeries ];
375+ Series * series = & plot -> series . data [iSeries ];
377376
378377 // Legend mark
379378 switch (series -> style .kind )
0 commit comments