Comparing version 1.4.0 to 1.4.1
@@ -62,3 +62,3 @@ "use strict"; | ||
type: _this.props.fetch, | ||
query: _this.query | ||
query: _.extend({}, _this.props.default, _this.query) | ||
}; | ||
@@ -80,3 +80,3 @@ _this.props.dispatch(param); | ||
type: this.props.fetch, | ||
query: this.query | ||
query: _.extend({}, this.props.default, this.query) | ||
}); | ||
@@ -110,3 +110,3 @@ }; | ||
type: this.props.fetch, | ||
query: query | ||
query: _.extend({}, this.props.default, query) | ||
}); | ||
@@ -113,0 +113,0 @@ }; |
@@ -127,2 +127,6 @@ import { TableProps, ColumnProps } from 'antd/lib/table/interface'; | ||
}; | ||
/** | ||
* 默认搜索参数 | ||
*/ | ||
default?: any; | ||
} |
@@ -80,2 +80,3 @@ "use strict"; | ||
this.DATA = this.props.data; | ||
this.sort(); | ||
this.update(); | ||
@@ -82,0 +83,0 @@ }; |
@@ -0,3 +1,9 @@ | ||
export interface Item { | ||
/** | ||
* 自定义属性 | ||
*/ | ||
[propName: string]: any; | ||
} | ||
export interface ChartOpts { | ||
data: any[]; | ||
data: Item[]; | ||
} | ||
@@ -4,0 +10,0 @@ export interface BarConfig { |
@@ -13,5 +13,14 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var _ = require("lodash"); | ||
var d3 = require("d3"); | ||
var D3Chart_1 = require("../D3Chart"); | ||
var utils_1 = require("../../../../vap/utils"); | ||
var DEFS = require('./defs.html'); | ||
var Formats = { | ||
number: function (from, to, p) { return Math.floor(from + p * (to - from)); }, | ||
usd: function (from, to, p) { return utils_1.Format.formatUSD(Math.floor(from + p * (to - from))); }, | ||
chinese: function (from, to, p) { return utils_1.Format.formatNumber(from + p * (to - from)); }, | ||
decimal: function (from, to, p) { return utils_1.Format.formatDecimal(from + p * (to - from)); }, | ||
percent: function (from, to, p) { return utils_1.Format.formatDecimal((from + p * (to - from)) * 100) + '%'; }, | ||
}; | ||
// 懒得写算法,最多支持8个label,写死,第三个参数以宽度为准, | ||
@@ -37,2 +46,17 @@ var POS = { | ||
], | ||
'5': [ | ||
[0.5, 0.2, 0.12], | ||
[0.2, 0.45, 0.12], | ||
[0.3, 0.8, 0.12], | ||
[0.7, 0.8, 0.12], | ||
[0.8, 0.45, 0.12], | ||
], | ||
'6': [ | ||
[0.3, 0.2, 0.12], | ||
[0.7, 0.2, 0.12], | ||
[0.8, 0.5, 0.12], | ||
[0.7, 0.8, 0.12], | ||
[0.3, 0.8, 0.12], | ||
[0.2, 0.5, 0.12], | ||
], | ||
}; | ||
@@ -43,11 +67,21 @@ var SPLIT = 4; | ||
function default_1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.format = Formats.number; | ||
_this.group = null; | ||
return _this; | ||
} | ||
default_1.prototype.resize = function () { | ||
console.log('resize'); | ||
// console.log('resize') | ||
}; | ||
default_1.prototype.build = function () { | ||
var _this = this; | ||
var valueField = this.props.valueField; | ||
var labelField = this.props.labelField; | ||
var coord = POS[this.DATA.length + '']; | ||
this.SVG.attr('class', '_vc_label'); | ||
this.SVG.append('defs').html(DEFS); | ||
if (_.has(this.props, 'format') && _.has(Formats, this.props.format)) { | ||
this.format = Formats[this.props.format]; | ||
} | ||
// this.SVG.datum(this.DATA); | ||
//超过1个Label时,绘制连接线 | ||
@@ -64,9 +98,7 @@ if (this.DATA.length > 1) { | ||
} | ||
var line = d3.line().x(function (d) { return d[0]; }).y(function (d) { return d[2]; }) | ||
.curve(d3.curveBasisClosed); | ||
var line = d3.line().x(function (d) { return d[0]; }).y(function (d) { return d[2]; }).curve(d3.curveLinearClosed); | ||
this.SVG.append('path') | ||
.datum(LineData) | ||
.attr('d', line) | ||
.attr('fill', 'transparent') | ||
.attr('stroke', '#ccc') | ||
.attr('class', '_joint') | ||
.attr('id', 'line-joint'); | ||
@@ -82,23 +114,64 @@ this.SVG.append('use') | ||
} | ||
var group = this.SVG.selectAll('g.item').data(this.DATA).enter().append('g').attr('class', 'item'); | ||
var circle = group.append('circle') | ||
this.group = this.SVG.selectAll('g._item').data(this.DATA, function (d) { return d[labelField]; }).enter().append('g').attr('class', '_item'); | ||
this.group.classed('_item_cursor', _.has(this.props, 'onClick')); | ||
if (_.has(this.props, 'onClick')) { | ||
this.group.on('click', function (d) { return _this.props.onClick(d); }); | ||
} | ||
var circle = this.group.append('circle') | ||
.attr('cx', function (d, i) { return coord[i][0] * _this.WIDTH; }) | ||
.attr('cy', function (d, i) { return coord[i][1] * _this.HEIGHT; }) | ||
.attr('r', function (d, i) { return coord[i][2] * _this.WIDTH; }) | ||
.attr('class', 'label') | ||
.attr('fill', 'white') | ||
.attr('stroke', '#cccccc') | ||
.attr('filter', 'url(#label-shadow)'); | ||
group.append('text') | ||
.text(function (d) { return d.label; }) | ||
.attr('class', '_bkg'); | ||
this.group.append('text') | ||
.text(function (d) { return d[_this.props.labelField]; }) | ||
.attr('x', function (d, i) { return coord[i][0] * _this.WIDTH; }) | ||
.attr('y', function (d, i) { return coord[i][1] * _this.HEIGHT - 10; }) | ||
.attr('text-anchor', 'middle'); | ||
group.append('text') | ||
.text(function (d) { return d.value; }) | ||
.attr('class', '_text'); | ||
var valueLabel = this.group.append('text') | ||
.text(function (d, i) { console.log(i); return 0; }) | ||
.attr('x', function (d, i) { return coord[i][0] * _this.WIDTH; }) | ||
.attr('y', function (d, i) { return coord[i][1] * _this.HEIGHT + 20; }) | ||
.attr('text-anchor', 'middle'); | ||
.attr('class', '_count'); | ||
var format = this.format; | ||
// @ts-ignore | ||
valueLabel.transition() | ||
.duration(2000) | ||
.on('start', function (d) { | ||
var from = 0; | ||
var to = d[valueField]; | ||
d3.active(this).tween('text', function () { | ||
var that = d3.select(this); | ||
return function (p) { | ||
that.text(format(from, to, p)); | ||
}; | ||
}); | ||
}); | ||
}; | ||
default_1.prototype.update = function () { | ||
var _this = this; | ||
var labelField = this.props.labelField; | ||
var valueField = this.props.valueField; | ||
var format = this.format; | ||
console.log(this.DATA); | ||
// let group = this.SVG.selectAll('g._item'); | ||
// console.log(this.DATA); | ||
this.group.data(this.DATA, function (d) { return d[labelField]; }).selectAll('text._count') | ||
.text(function (d, i, n, p) { | ||
console.log(d, i, n, p); | ||
console.log(_this.DATA[i]); | ||
return _this.DATA[i][valueField]; | ||
}); | ||
// group.enter().append('text').text('new'); | ||
// window['group'] = group; | ||
// console.log(group.enter()); | ||
// group.selectAll('text._count').data((d, i) => { console.log(d, i, this.DATA[i]); return this.DATA[i] }) | ||
// .text(d => { | ||
// console.log(d); | ||
// return d[valueField] | ||
// }) | ||
// this.SVG.datum(this.DATA).selectAll('text._count').data() | ||
// var g = svg.datum(data).selectAll(".arc") | ||
// .data(pie) | ||
// .enter().append("g") | ||
// .attr("class", "arc") | ||
}; | ||
@@ -108,1 +181,15 @@ return default_1; | ||
exports.default = default_1; | ||
function countUp(selector, to) { | ||
var from = selector.text(); | ||
selector.text(from) | ||
.transition() | ||
.duration(this.duration) | ||
.on('start', function () { | ||
d3.active(this).tween('text', function () { | ||
var that = d3.select(this); | ||
return function (p) { | ||
that.text(Math.floor(from + p * (to - from))); | ||
}; | ||
}); | ||
}); | ||
} |
@@ -147,3 +147,3 @@ "use strict"; | ||
this.SVG.append('defs').html(DEFS); | ||
this.BkgGroup = this.SVG.append('g').attr('class', '_group_area_bkg'); | ||
this.BkgGroup = this.SVG.append('g').attr('class', '_group_bkg'); | ||
; | ||
@@ -158,3 +158,3 @@ this.AreaGroup = this.SVG.append('g').attr('id', this.id + "_group_area").attr('class', "_group_area " + (this.Select ? '_group_area_selected' : '')); | ||
this.SVG.attr('height', this.THEIGHT) | ||
.attr('class', '_vap_map') | ||
.attr('class', '_vc_map') | ||
.attr('width', this.WIDTH) | ||
@@ -226,3 +226,3 @@ .style('height', this.THEIGHT); | ||
default_1.prototype.update = function () { | ||
this.build(); | ||
// this.build(); | ||
}; | ||
@@ -229,0 +229,0 @@ default_1.prototype.render = function () { |
{ | ||
"name": "vap", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "vap", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -123,3 +123,3 @@ "use strict"; | ||
} | ||
NProgress.start(); | ||
//NProgress.start(); | ||
// @ts-ignore | ||
@@ -129,3 +129,3 @@ return fetch(url, newOptions) | ||
.then(function (response) { | ||
NProgress.done(); | ||
// NProgress.done(); | ||
return response.json(); | ||
@@ -132,0 +132,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237190
6211
100