It works! Yay!
[scdataviz] / graph.c
diff --git a/graph.c b/graph.c
index 531f77a..6da0fb6 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -5,20 +5,22 @@
 ** Login   <solarion@johnathan>
 ** 
 
-Copyright (C) 2008 Joseph Pingenot
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+    Copyright (C) 2008 Joseph Pingenot
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU Lesser General Public License for more details.
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-You should have received a copy of the GNU Lesser General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 **Many thanks to Davyd Madeley for the excellent Cairo  Tutorial
 **  at http://gnomejournal.org/article/34/writing-a--using-cairo-and-gtk28
@@ -27,7 +29,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ** Last update Sun May 12 01:17:25 2002 Speed Blue
 */
 
-#include "graph.h"
+#include <graph.h>
+#include <stdlib.h>
 
 G_DEFINE_TYPE(Graph, graph, G_TYPE_OBJECT);
 
@@ -38,11 +41,11 @@ static void graph_class_init(GraphClass *klass) {
 
 static void graph_init(Graph *graph) {
   graph->symbol = CIRCLE;
-  GPtrArray = g_ptr_array_new();
+  graph->points = g_ptr_array_new();
 }
 
 Graph *graph_new(void) {
-  return g_object_new(G_GRAPH_TYPE);
+  return g_object_new(GRAPH_TYPE, NULL);
 }
 
 int graph_add_point(Graph* graph, double x, double y) {
@@ -51,14 +54,14 @@ int graph_add_point(Graph* graph, double x, double y) {
   point[0] = x;
   point[1] = y;
   g_ptr_array_add(graph->points, (gpointer)point);
-  if(points->len == 1) {
-    maxx = minx = x;
-    maxy = miny = x;
+  if(graph->points->len == 1) {
+    graph->maxx = graph->minx = x;
+    graph->maxy = graph->miny = y;
   }else{
-    if(x > maxx) maxx = x;
-    if(x < minx) minx = x;
-    if(y > mayy) maxy = y;
-    if(y < miny) miny = y;
+    if(x > graph->maxx) graph->maxx = x;
+    if(x < graph->minx) graph->minx = x;
+    if(y > graph->maxy) graph->maxy = y;
+    if(y < graph->miny) graph->miny = y;
   }
   return 0;
 }