| 77 | } |
| 78 | |
| 79 | pushData(target, name, value, color) |
| 80 | { |
| 81 | if((this.props.type+"").trim()=="line") |
| 82 | { |
| 83 | if(target==this.props.target && ((this.props.filter+"").trim().indexOf(name)!=-1 || (this.props.filter.trim()+"").length==0)) |
| 84 | { |
| 85 | let found = false; |
| 86 | |
| 87 | for(let i in this.state.chart.data.datasets) |
| 88 | { |
| 89 | let dataset = this.state.chart.data.datasets[i]; |
| 90 | if(dataset.label==name) |
| 91 | { |
| 92 | found = true; |
| 93 | |
| 94 | dataset.data.push(value); |
| 95 | if(dataset.data.length>this.props.limit) |
| 96 | { |
| 97 | dataset.splice(0, 1) |
| 98 | } |
| 99 | |
| 100 | if(this.state.chart.data.labels.length<dataset.data.length) |
| 101 | this.state.chart.data.labels.push(this.state.chart.data.labels.length); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | if(!found) |
| 106 | { |
| 107 | if(this.state.chart.data.labels.length==0) |
| 108 | this.state.chart.data.labels.push(0); |
| 109 | |
| 110 | this.state.chart.data.datasets.push({ |
| 111 | data: [value], |
| 112 | label: name, |
| 113 | borderColor: color, |
| 114 | fill: false |
| 115 | }); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | this.state.chart.update(); |
| 121 | } |
| 122 | |
| 123 | pushPieData(target, name, color) |
| 124 | { |