/**
  * Parses the parameters for the chart and sets them to the pChart object
  *
  * @param	$args	Array	Associative array with arguments given by the user
  * @returns			pChart	pChart object with parameters set
  */
 public function parseArgs($args, $default = false)
 {
     // Do all default parsing
     parent::parseArgs($args, $default);
     // Draw a filled radar graph instead of an empty one
     if (array_key_exists("filled", $args)) {
         if ($args["filled"] != "false") {
             $this->chartArgs["filled"] = true;
         }
     }
     // Draw stripes underneath the graph
     if (array_key_exists("striped", $args)) {
         if ($args["striped"] != "false") {
             $this->chartArgs["striped"] = true;
         }
     }
     // What color should be used for the graph background
     if (array_key_exists("stripecolor", $args)) {
         $this->chartArgs["stripecolor"] = wfPChart4mwhtml2rgb($args["stripecolor"]);
     }
     return $this->chartArgs;
 }
 /**
  * Parses the parameters for the chart and sets them to the pChart object
  *
  * @param	$args		Array	Associative array with arguments given by the user
  * @param	$default	Array	Default parameters (optional)
  * @returns				pChart	pChart object with parameters set
  */
 public function parseArgs($args, $default = false)
 {
     // Initialize default arguments
     if (!$default) {
         $chartArgs = $this->getDefaultArgs();
     } else {
         $chartArgs = $default;
     }
     // Check whether several TITLE parameters are set by the user
     if (array_key_exists("title", $args)) {
         $chartArgs["title"] = $args["title"];
     }
     if (array_key_exists("titlefont", $args) && preg_match('/\\/|\\|\\.\\./', $args["titlefont"]) == 0) {
         $chartArgs["titlefont"] = $args["titlefont"];
     }
     if (array_key_exists("titlesize", $args)) {
         $chartArgs["titlesize"] = $args["titlesize"];
     }
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("titlecolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["titlecolor"]);
         if ($cArray) {
             $chartArgs["titlecolor"] = $cArray;
         }
     }
     // Check whether several TEXT parameters are set by the user
     if (array_key_exists("textfont", $args) && preg_match('/\\/|\\|\\.\\./', $args["textfont"]) == 0) {
         $chartArgs["textfont"] = $args["textfont"];
     }
     if (array_key_exists("textsize", $args)) {
         $chartArgs["textsize"] = $args["textsize"];
     }
     // Determine the size of the chart
     if (array_key_exists("size", $args) && trim($args["size"]) != "") {
         // Size can be set as one number, or 00x00 for width x height
         $sizes = explode("x", strtolower($args["size"]));
         // If only one number is given, it is taken as the height and width
         // so the chart will be a square
         if (count($sizes) == 1 && is_numeric($sizes[0])) {
             $chartArgs["sizeX"] = $sizes[0];
             $chartArgs["sizeY"] = $sizes[0];
         }
         if (count($sizes) > 1) {
             if (is_numeric($sizes[0])) {
                 $chartArgs["sizeX"] = $sizes[0];
             }
             if (is_numeric($sizes[1])) {
                 $chartArgs["sizeY"] = $sizes[1];
             }
         }
     }
     // Are the colors set? If so, set the colors into the color palette
     if (array_key_exists("colors", $args)) {
         $colors = explode(",", $args["colors"]);
         $chartArgs["colors"] = array();
         // Set all colors into the palette, if it is a correct RGB color
         // If it is not a correct RGB color, black is used
         foreach ($colors as $color) {
             $cArray = wfPChart4mwhtml2rgb($color);
             if (!$cArray) {
                 $cArray = array(0, 0, 0);
             }
             $chartArgs["colors"][] = $cArray;
         }
     }
     // Has the user specified a colorscheme to be used?
     if (array_key_exists("colorscheme", $args)) {
         global $wgPChart4mwDefaultColorSchemeDir;
         $filename = $wgPChart4mwDefaultColorSchemeDir . '/' . $args["colorscheme"] . '.txt';
         if (file_exists($filename)) {
             $chartArgs["colorscheme"] = $args["colorscheme"];
         }
     }
     // What color should be used for the image background
     // If no correct color is specified, the default color is used
     if (array_key_exists("bgcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["bgcolor"]);
         if ($cArray) {
             $chartArgs["bgcolor"] = $cArray;
         }
     }
     // Set the margins on left and right side
     if (array_key_exists("marginx", $args) && is_numeric($args["marginx"])) {
         $chartArgs["marginX"] = $args["marginx"];
     }
     // Set the margins on top and bottom
     if (array_key_exists("marginy", $args) && is_numeric($args["marginy"])) {
         $chartArgs["marginY"] = $args["marginy"];
     }
     // Should the labels be printed?
     if (array_key_exists("labels", $args)) {
         $chartArgs["labels"] = strtolower($args["labels"]) != "false";
     }
     // Should every label be printed, or should some be skipped
     // See skiplabels parameter of pChart->drawScale()
     if (array_key_exists("skiplabels", $args) && is_numeric($args["skiplabels"])) {
         $chartArgs["skiplabels"] = $args["skiplabels"];
     }
     // How many decimals should be shown on the Y-axis
     // See decimals parameter of pChart->drawScale()
     if (array_key_exists("decimals", $args) && is_numeric($args["decimals"])) {
         $chartArgs["decimals"] = $args["decimals"];
     }
     // Should the labels be printed with an angle?
     // The angle should be between 0 and 180 degrees
     if (array_key_exists("angle", $args)) {
         $angle = (int) $args["angle"];
         if ($angle >= 0 && $angle <= 180) {
             $chartArgs["angle"] = $angle;
         }
     }
     // What color should be used for the graph background
     if (array_key_exists("axiscolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["axiscolor"]);
         if ($cArray) {
             $chartArgs["axiscolor"] = $cArray;
         }
     }
     // What color should be used for the graph background
     if (array_key_exists("axis", $args)) {
         if (strtolower($args["axis"]) == "false") {
             $chartArgs["axiscolor"] = $chartArgs["bgcolor"];
         }
     }
     // Show or hide the grid in the chart
     if (array_key_exists("box", $args)) {
         $chartArgs["box"] = $args["box"] != "false";
     }
     // What color should be used for the box
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("boxcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["boxcolor"]);
         if ($cArray) {
             $chartArgs["boxcolor"] = $cArray;
         }
     }
     // Are the max and min values for the Y axis given?
     if (array_key_exists("ymax", $args)) {
         $chartArgs["autoscaling"] = false;
         $chartArgs["ymax"] = $args["ymax"];
         if (!array_key_exists("ymin", $args)) {
             $chartArgs["ymin"] = 0;
         }
     }
     // If the ymin value is given, save it. If it is zero, it can be used to fix the y-axis min value to zero
     // other values are only used in combination with ymax
     if (array_key_exists("ymin", $args)) {
         $chartArgs["ymin"] = $args["ymin"];
     }
     // Show or hide the grid in the chart
     if (array_key_exists("grid", $args)) {
         $chartArgs["grid"] = $args["grid"] != "false";
     }
     // What color should be used for the grid
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("gridcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["gridcolor"]);
         if ($cArray) {
             $chartArgs["gridcolor"] = $cArray;
         }
     }
     // Use a background gradient or not
     if (array_key_exists("bgtype", $args)) {
         if ($args["bgtype"] == "gradient") {
             $chartArgs["bgtype"] = "gradient";
         }
     }
     // What color should be used for the graph background
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("graphbgcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["graphbgcolor"]);
         if ($cArray) {
             $chartArgs["graphbgcolor"] = $cArray;
         }
     }
     // Use a background gradient or not
     if (array_key_exists("graphbgtype", $args)) {
         if ($args["graphbgtype"] == "gradient" || $args["graphbgtype"] == "normal" || $args["graphbgtype"] == "transparent") {
             $chartArgs["graphbgtype"] = $args["graphbgtype"];
         }
     }
     // Should the legend be set?
     if (array_key_exists("legend", $args)) {
         $chartArgs["legend"] = $args["legend"] != "none";
         $chartArgs["legendpos"] = $args["legend"];
     }
     // What color should be used for the text in the legend
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("legendcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["legendcolor"]);
         if ($cArray) {
             $chartArgs["legendcolor"] = $cArray;
         }
     }
     // What color should be used for the legend background
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("legendbgcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["legendbgcolor"]);
         if ($cArray) {
             $chartArgs["legendbgcolor"] = $cArray;
         }
     }
     // What color should be used for the legend border
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("legendbordercolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["legendbordercolor"]);
         if ($cArray) {
             $chartArgs["legendbordercolor"] = $cArray;
         }
     }
     // Check how transparent the bars or graph area should be
     if (array_key_exists("opacity", $args)) {
         if ($args["opacity"] >= 0 && $args["opacity"] <= 100) {
             $chartArgs["opacity"] = $args["opacity"];
         }
     }
     // Title for the X-axis
     if (array_key_exists("xtitle", $args)) {
         $chartArgs["xtitle"] = $args["xtitle"];
     }
     // Title for the Y-axis
     if (array_key_exists("ytitle", $args)) {
         $chartArgs["ytitle"] = $args["ytitle"];
     }
     // Unit for the X-axis
     if (array_key_exists("xunit", $args)) {
         $chartArgs["xunit"] = $args["xunit"];
     }
     // Unit for the Y-axis
     if (array_key_exists("yunit", $args)) {
         $chartArgs["yunit"] = $args["yunit"];
     }
     // Format for values on the X-axis
     if (array_key_exists("xformat", $args)) {
         $chartArgs["xformat"] = $args["xformat"];
     }
     // Format for values on the Y-axis
     if (array_key_exists("yformat", $args)) {
         $chartArgs["yformat"] = $args["yformat"];
     }
     // Are there non-numeric labels in the data
     if (array_key_exists("xlabels", $args)) {
         $chartArgs["xlabels"] = strtolower($args["xlabels"]) != "false";
     }
     // Are there non-numeric labels in the data
     if (array_key_exists("ylabels", $args)) {
         $chartArgs["ylabels"] = strtolower($args["ylabels"]) != "false";
     }
     // Threshold line
     if (array_key_exists("threshold", $args)) {
         if (is_numeric($args["threshold"])) {
             $chartArgs["threshold"] = $args["threshold"];
         }
     }
     // What color should be used for the grid
     // If the color is not correctly specified (HTML-style), the default color is used
     if (array_key_exists("thcolor", $args)) {
         $cArray = wfPChart4mwhtml2rgb($args["thcolor"]);
         if ($cArray) {
             $chartArgs["thcolor"] = $cArray;
         }
     }
     // Save the arguments
     $this->chartArgs = $chartArgs;
     return $this->chartArgs;
 }