-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chart.php
41 lines (36 loc) · 1.08 KB
/
Chart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// Lucas Tiago de Moraes
// include class DHX
include_once 'DHX.php';
// class Chart
class Chart extends DHX {
private $document; // ref document
private $data; // ref data
// auto construct
function __construct($value = ''){
if($value){
$this->encoding($value);
}
$this->document = $this->document();
$this->data = $this->document->appendChild(new DOMElement('data'));
}
// public item
public function item(){
$data = func_get_args();
foreach($data as $row){
$item = $this->data->appendChild(new DOMElement('item'));
foreach($row as $key => $value){
if($key == 'id'){
$item->setAttributeNode(new DOMAttr($key, $value));
}else{
$k = $item->appendChild(new DOMElement($key));
$k->appendChild($this->document->createTextNode($value));
}
}
}
}
// public result
public function result(){
return $this->document->saveXML();
}
}