mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:59:17 +08:00
parent
27642497ff
commit
6b2ccdba41
@ -1,9 +1,11 @@
|
|||||||
export default {
|
export default {
|
||||||
|
type: 'page',
|
||||||
type: 'page',
|
type: 'page',
|
||||||
title: '标题',
|
title: '标题',
|
||||||
remark: {
|
remark: {
|
||||||
title: '标题',
|
title: '标题',
|
||||||
body: '这是一段描述问题,注意到了没,还可以设置标题。而且只有点击了才弹出来。',
|
body:
|
||||||
|
'这是一段描述问题,注意到了没,还可以设置标题。而且只有点击了才弹出来。',
|
||||||
icon: 'question-mark',
|
icon: 'question-mark',
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
|
@ -54,10 +54,15 @@ export interface ChartSchema extends BaseSchema {
|
|||||||
initFetchOn?: SchemaExpression;
|
initFetchOn?: SchemaExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置echart的config
|
* 配置echart的config,支持数据映射。如果用了数据映射,为了同步更新,请设置 trackExpression
|
||||||
*/
|
*/
|
||||||
config?: any;
|
config?: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跟踪表达式,如果这个表达式的运行结果发生变化了,则会更新 Echart,当 config 中用了数据映射时有用。
|
||||||
|
*/
|
||||||
|
trackExpression?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 宽度设置
|
* 宽度设置
|
||||||
*/
|
*/
|
||||||
@ -214,6 +219,13 @@ export class Chart extends React.Component<ChartProps> {
|
|||||||
}
|
}
|
||||||
} else if (props.config !== prevProps.config) {
|
} else if (props.config !== prevProps.config) {
|
||||||
this.renderChart(props.config || {});
|
this.renderChart(props.config || {});
|
||||||
|
} else if (
|
||||||
|
props.config &&
|
||||||
|
props.trackExpression &&
|
||||||
|
filter(props.trackExpression, props.data) !==
|
||||||
|
filter(prevProps.trackExpression, prevProps.data)
|
||||||
|
) {
|
||||||
|
this.renderChart(props.config || {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,32 @@ export const filters: {
|
|||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
raw: input => input,
|
raw: input => input,
|
||||||
|
now: () => new Date(),
|
||||||
|
toDate: (input: any, inputFormat = '') => {
|
||||||
|
const data = moment(input, inputFormat);
|
||||||
|
data.add();
|
||||||
|
return data.isValid() ? data.toDate() : undefined;
|
||||||
|
},
|
||||||
|
dateModify: (
|
||||||
|
input: any,
|
||||||
|
modifier: 'add' | 'subtract' | 'endOf' | 'startOf' = 'add',
|
||||||
|
amount = 0,
|
||||||
|
unit = 'days'
|
||||||
|
) => {
|
||||||
|
if (!(input instanceof Date)) {
|
||||||
|
input = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modifier === 'endOf' || modifier === 'startOf') {
|
||||||
|
return moment(input)
|
||||||
|
[modifier === 'endOf' ? 'endOf' : 'startOf'](amount || 'day')
|
||||||
|
.toDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
return moment(input)
|
||||||
|
[modifier === 'add' ? 'add' : 'subtract'](amount, unit)
|
||||||
|
.toDate();
|
||||||
|
},
|
||||||
date: (input, format = 'LLL', inputFormat = 'X') =>
|
date: (input, format = 'LLL', inputFormat = 'X') =>
|
||||||
moment(input, inputFormat).format(format),
|
moment(input, inputFormat).format(format),
|
||||||
number: input => {
|
number: input => {
|
||||||
@ -214,6 +240,15 @@ export const filters: {
|
|||||||
last: input => input && (input.length ? input[input.length - 1] : null),
|
last: input => input && (input.length ? input[input.length - 1] : null),
|
||||||
minus: (input, step = 1) => (parseInt(input, 10) || 0) - parseInt(step, 10),
|
minus: (input, step = 1) => (parseInt(input, 10) || 0) - parseInt(step, 10),
|
||||||
plus: (input, step = 1) => (parseInt(input, 10) || 0) + parseInt(step, 10),
|
plus: (input, step = 1) => (parseInt(input, 10) || 0) + parseInt(step, 10),
|
||||||
|
sum: (input, field) =>
|
||||||
|
Array.isArray(input)
|
||||||
|
? input.reduce(
|
||||||
|
(sum, item) =>
|
||||||
|
sum + (parseFloat(field ? pickValues(field, item) : item) || 0),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
: input,
|
||||||
|
abs: (input: any) => (typeof input === 'number' ? Math.abs(input) : input),
|
||||||
pick: (input, path = '&') =>
|
pick: (input, path = '&') =>
|
||||||
Array.isArray(input) && !/^\d+$/.test(path)
|
Array.isArray(input) && !/^\d+$/.test(path)
|
||||||
? input.map((item, index) =>
|
? input.map((item, index) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user