             "],"
             "label: '" (:label datum) "'},\n")))
 
+(defn legend-part
+    [show-legend legend-position legend-background]
+    (str "legend:{
+              show: "             (bool->string show-legend) ",
+              position: '"        (or legend-position "ne") "',
+              backgroundColor: '" (or legend-background "#D2E8FF") "',
+          }"))
+
 (defn pie-chart
     "Creates a simple pie chart. Please look at the function named
      'test-pie-charts' how to use pie-chart."

                      horizontalLines: " (bool->string horizontal-lines) "
                  },
                  xaxis: {showLabels: true},
                  yaxis: {showLabels: true}, 
                  legend:{
                      show: "             (bool->string show-legend) ",
                      position: '"        (or legend-position "ne") "',
                      backgroundColor: '" (or legend-background "#D2E8FF") "',
                  }"
                  (if title    (str ", title: '" title "'"))
                  (if subtitle (str ", subtitle: '" subtitle "'"))
                  "});")]])

                  },
                  xaxis: {showLabels: true},
                  yaxis: {showLabels: true}, 
                  bars: {show: true, stacked: true, barWidth: " (or bar-width "0.5") "},"
                  (legend-part show-legend legend-position legend-background)
                  "});")]])

