Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data() {
const dv = new DataSet.View().source(this.dataSource)
dv.transform({
type: 'fold',
fields: this.fields,
key: 'x',
value: 'y'
})
let rows = dv.rows
// 替换别名
rows.forEach(row => {
for (let item of this.aliases) {
if (item.field === row.x) {
row.x = item.alias
break
}
}
})
renderMap(){
const dv = new DataSet.View().source(this.state.data);
dv.transform({
type: 'fold',
fields: ['A'],
key: 'type',
value: 'value',
});
const scale = {
value: {
alias: 'The Share Price in Dollars',
formatter: (val) => {
return `该月份订单量${val}`;
},
},
year: {
range: [0, 1],
toData( model: Model ) {
if ( !model.data )
return [];
let dataView = new DataSet.View().source( model.data );
dataView.transform( {
type: "fold",
fields: model.columns,
key: "key",
value: "value",
} );
return dataView.rows;
}
render() {
const data = [
{ month: '2018-01', Maths: 0, English: 0 },
{ month: '2018-02', Maths: 90, English: 60 },
{ month: '2018-03', Maths: 10, English: 80 },
{ month: '2018-04', Maths: 90, English: 20 },
{ month: '2018-05', Maths: 20, English: 70 },
{ month: '2018-06', Maths: 80, English: 59 },
{ month: '2018-07', Maths: 0, English: 0 },
];
const dv = new DataSet.View().source(data);
dv.transform({
type: 'fold',
fields: ['Maths', 'English'],
key: 'type',
value: 'value',
});
const scale = {
value: {
alias: 'The Share Price in Dollars',
formatter: (val) => {
return `${val}`;
},
},
month: {
range: [0, 1],
drawChart(){
let temp = sourceDataConst;
if(this.sourceData && this.sourceData.length>0){
temp = this.sourceData
}
const dv = new DataSet.View().source(temp);
dv.transform({
type: 'fold',
fields:(!this.fields||this.fields.length==0)?fieldsConst:this.fields,
key: 'x',
value: 'y',
});
this.chartData=dv.rows;
}
}
toData(model: Model) {
let dataView = new DataSet.View().source(model.data);
if (model.columns.length === 0)
return dataView.rows;
if (model.columns.length === 1) {
dataView.transform({
type: "percent",
field: model.columns[0],
dimension: 'name',
as: 'percent'
});
return dataView.rows;
}
dataView.transform({
type: "percent",
fields: model.columns,
dimension: 'name',
as: 'percent'