/** * Sets the number format characters */ public static function SetNumStringOptions($decimal, $thousands) { Graph::$decimal = $decimal; Graph::$thousands = $thousands; }
/** * Returns the SVG document */ public function Fetch($header = TRUE, $defer_javascript = TRUE) { $content = ''; if ($header) { $content .= '<?xml version="1.0"'; // encoding comes before standalone if (strlen($this->encoding) > 0) { $content .= " encoding=\"{$this->encoding}\""; } // '>' is with \n so as not to confuse syntax highlighting $content .= " standalone=\"no\"?" . ">\n"; if ($this->doctype) { $content .= '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ' . '"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' . "\n"; } } // set the precision - PHP default is 14 digits! Graph::$precision = $this->settings['precision']; $old_precision = ini_set('precision', Graph::$precision); // set decimal and thousands for NumString Graph::$decimal = $this->settings['decimal']; Graph::$thousands = $this->settings['thousands']; // display title and description if available $heading = ''; if ($this->title) { $heading .= $this->Element('title', NULL, NULL, $this->title); } if ($this->description) { $heading .= $this->Element('desc', NULL, NULL, $this->description); } try { $this->CheckValues($this->values); if ($this->show_tooltips) { $this->LoadJavascript(); } // get the body content from the subclass $body = $this->DrawGraph(); } catch (Exception $e) { $body = $this->ErrorText($e->getMessage()); } $svg = array('width' => $this->width, 'height' => $this->height, 'version' => '1.1', 'xmlns:xlink' => 'http://www.w3.org/1999/xlink'); if (!$defer_javascript) { $js = $this->FetchJavascript(); if ($js != '') { $heading .= $js; $onload = Graph::$javascript->GetOnload(); if ($onload != '') { $svg['onload'] = $onload; } } } // insert any gradients that are used foreach ($this->gradients as $key => $gradient) { $this->defs[] = $this->MakeLinearGradient($key); } // and any patterns if (!is_null($this->pattern_list)) { $this->pattern_list->MakePatterns($this->defs); } // show defs and body content if (count($this->defs)) { $heading .= $this->Element('defs', NULL, NULL, implode('', $this->defs)); } if ($this->namespace) { $svg['xmlns:svg'] = "http://www.w3.org/2000/svg"; } else { $svg['xmlns'] = "http://www.w3.org/2000/svg"; } // add any extra namespaces foreach ($this->namespaces as $ns => $url) { $svg['xmlns:' . $ns] = $url; } // display version string if ($this->show_version) { $text = array('x' => $this->pad_left, 'y' => $this->height - 3); $style = array('font-family' => 'monospace', 'font-size' => '12px', 'font-weight' => 'bold'); $body .= $this->ContrastText($text['x'], $text['y'], SVGGRAPH_VERSION, 'blue', 'white', $style); } $content .= $this->Element('svg', $svg, NULL, $heading . $body); // replace PHP's precision ini_set('precision', $old_precision); if ($this->minify) { $content = preg_replace('/\\>\\s+\\</', '><', $content); } return $content; }