* Bowing params are working better.
[scdataviz] / graph.c
diff --git a/graph.c b/graph.c
index 1af3cb8..507e557 100644 (file)
--- a/graph.c
+++ b/graph.c
@@ -44,6 +44,7 @@ static void graph_init(Graph *graph) {
   graph->symbol = CIRCLE;
   graph->points = g_ptr_array_new();
   graph->lines = NULL;
+  graph->xaxis = graph->yaxis = NULL;
 }
 
 Graph *graph_new(void) {
@@ -82,6 +83,7 @@ int graph_add_point(Graph* graph, double x, double y, const GString *label) {
 }
 
 int graph_add_graph_line(Graph* graph, struct graph_line *l) {
+  if(l == NULL) return 1;
   if(graph->lines == NULL) {
     if((graph->lines = g_ptr_array_new()) == NULL) return 1;
   }
@@ -159,3 +161,32 @@ void graph_bezier_quadratic_to_cubic(double x0, double x3, double *x1, double *x
   *x2 = (x3-2.0*(*x1))/3.0;
   *x1 = (x0-2.0*(*x1))/3.0;
 }
+
+void graph_set_xaxis(Graph *g, struct graph_axis *axis) {
+  if(g->xaxis != NULL) {
+    free(g->xaxis);
+  }
+  g->xaxis=axis;
+}
+void graph_set_yaxis(Graph *g, struct graph_axis *axis) {
+  if(g->yaxis != NULL) {
+    free(g->yaxis);
+  }
+  g->yaxis=axis;
+}
+
+void graph_autoset_xaxis(Graph *g) {
+  struct graph_axis *axis;
+  if((axis=(struct graph_axis *)malloc(sizeof(struct graph_axis))) == NULL) {
+    return 1;
+  }
+  graph_set_xaxis(g, axis);
+}
+
+void graph_autoset_yaxis(Graph *g) {
+  struct graph_axis *axis;
+  if((axis=(struct graph_axis *)malloc(sizeof(struct graph_axis))) == NULL) {
+    return 1;
+  }
+  graph_set_xaxis(g, axis);
+}