| | |
| | | if (_config.plot.datatype === 'statistics') { |
| | | if (_config.plot.ramp === 'true') { |
| | | let _s = 'l(0) ' |
| | | if (_config.plot.chartType === 'bar') { |
| | | if (_config.plot.chartType === 'bar' || (_config.plot.chartType === 'line' && _config.plot.rampDirection === 'vertical')) { |
| | | _s = 'l(90) ' |
| | | } |
| | | _config.plot.colors.forEach(item => { |
| | |
| | | } else { |
| | | if (_config.plot.ramp === 'true') { |
| | | let _s = 'l(0) ' |
| | | if (_config.plot.chartType === 'bar') { |
| | | if (_config.plot.chartType === 'bar' || (_config.plot.chartType === 'line' && _config.plot.rampDirection === 'vertical')) { |
| | | _s = 'l(90) ' |
| | | } |
| | | _config.plot.colors.forEach(item => { |
| | |
| | | if (plot.repeat === 'average') { |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | if (!item[plot.Xaxis]) return |
| | | |
| | | vFields.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | |
| | | } |
| | | }) |
| | | |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | // dodge is not support linear attribute, please use category attribute! 时间格式 |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | if (!_mdata.has(item[plot.Xaxis])) { |
| | | item.$count = 1 |
| | | _mdata.set(item[plot.Xaxis], item) |
| | | } else if (item[plot.Xaxis]) { |
| | | } else { |
| | | let _item = _mdata.get(item[plot.Xaxis]) |
| | | _item.$count++ |
| | | vFields.forEach(col => { |
| | |
| | | } else if (plot.repeat === 'cumsum') { |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | if (!item[plot.Xaxis]) return |
| | | |
| | | vFields.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | |
| | | } |
| | | }) |
| | | |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | if (!_mdata.has(item[plot.Xaxis])) { |
| | | _mdata.set(item[plot.Xaxis], item) |
| | | } else if (item[plot.Xaxis]) { |
| | | } else { |
| | | let _item = _mdata.get(item[plot.Xaxis]) |
| | | vFields.forEach(col => { |
| | | _item[col.field] += item[col.field] |
| | |
| | | } else { // plot.repeat === 'unrepeat' |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | if (!item[plot.Xaxis]) return |
| | | |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | if (!_mdata.has(item[plot.Xaxis])) { |
| | | vFields.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | |
| | | _cdata.forEach(item => { |
| | | if (!item[plot.InfoType] || !item[plot.Xaxis]) return |
| | | |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | item.$uuid = item[plot.InfoType] + item[plot.Xaxis] |
| | | if (typeof(item[plot.InfoValue]) !== 'number') { |
| | | item[plot.InfoValue] = parseFloat(item[plot.InfoValue]) |
| | |
| | | _cdata.forEach(item => { |
| | | if (!item[plot.InfoType] || !item[plot.Xaxis]) return |
| | | |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | item.$uuid = item[plot.InfoType] + item[plot.Xaxis] |
| | | |
| | | if (typeof(item[plot.InfoValue]) !== 'number') { |
| | |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | if (!item[plot.InfoType] || !item[plot.Xaxis]) return |
| | | |
| | | if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) { |
| | | item[plot.Xaxis] = ' ' + item[plot.Xaxis] |
| | | } |
| | | |
| | | item.$uuid = item[plot.InfoType] + item[plot.Xaxis] |
| | | |
| | |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (plot.$colors.has(key)) { |
| | | if (plot.area === 'true' && plot.rampDirection === 'vertical') { |
| | | return plot.$colors.get(key).replace(/l\(9?0\) 0:|\s1:.*/ig, '') |
| | | } |
| | | return plot.$colors.get(key) |
| | | } else { |
| | | colorIndex++ |
| | |
| | | customrender = (data) => { |
| | | const { plot, transfield } = this.state |
| | | const ds = new DataSet() |
| | | const dv = ds.createView().source(data) |
| | | |
| | | let _copydata = data |
| | | // dodge is not support linear attribute, please use category attribute! 时间格式 |
| | | if (_copydata[0] && _copydata[0][plot.Xaxis] && /^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(_copydata[0][plot.Xaxis])) { |
| | | for (let i = 1; i < 12; i++) { |
| | | if (_copydata[i] && _copydata[i][plot.Xaxis] === _copydata[0][plot.Xaxis]) { |
| | | _copydata[i][plot.Xaxis] += ' ' |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | _copydata[0][plot.Xaxis] += ' ' |
| | | } |
| | | |
| | | const dv = ds.createView().source(_copydata) |
| | | dv.transform({ |
| | | type: 'map', |
| | | callback(row) { |
| | |
| | | padding |
| | | }) |
| | | const dst = new DataSet() |
| | | const dvt = dst.createView().source(_copydata) |
| | | const dvt = dst.createView().source(data) |
| | | |
| | | dvt.transform({ |
| | | type: 'fold', |
| | |
| | | let _data = [] |
| | | let _valfield = 'value' |
| | | let _typefield = 'key' |
| | | |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.datatype === 'statistics') { |
| | |
| | | autoFit: true, |
| | | height: plot.height |
| | | }) |
| | | |
| | | // dodge is not support linear attribute, please use category attribute! 时间格式 |
| | | if (_data[0] && _data[0][plot.Xaxis] && /^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(_data[0][plot.Xaxis])) { |
| | | for (let i = 1; i < 12; i++) { |
| | | if (_data[i] && _data[i][plot.Xaxis] === _data[0][plot.Xaxis]) { |
| | | _data[i][plot.Xaxis] += ' ' |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | _data[0][plot.Xaxis] += ' ' |
| | | } |
| | | |
| | | chart.data(_data) |
| | | |