@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
110 lines (109 loc) • 5.55 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import * as _ from 'lodash';
import { computed } from 'mobx';
import RelationBaseChartStore from '../stores/relation-base';
import { getTooltip } from './constants';
import { formatString } from '../../../services/language';
import { BaseLocale } from '../../../constants/language/base/type';
import { RelationLocale } from '../../../constants/language/relation/type';
var RelationChartStore = /** @class */ (function (_super) {
__extends(RelationChartStore, _super);
function RelationChartStore() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(RelationChartStore.prototype, "options", {
get: function () {
var _this = this;
return {
tooltip: {
trigger: 'item',
padding: [4, 8],
position: function (_point, _params, dom) {
dom.style.transform = 'translateZ(0)';
},
formatter: function (params) {
var metricDisplayName = _this.metricDisplayName;
var unitTransformer = _this.chartStyleService.unitTransformer;
if (params.data === undefined) {
return formatString(BaseLocale.status.empty);
}
if (params.dataType === 'node') {
return getTooltip(params.name, formatString(RelationLocale.outflow_text), unitTransformer(params.data.size));
}
var _a = params.data, target = _a.target, source = _a.source, sizes = _a.sizes;
var titles = [target + " -> " + source, source + " -> " + target];
var res = '';
sizes.forEach(function (size, index) {
if (size) {
res += getTooltip(titles[index], metricDisplayName, unitTransformer(size));
}
});
return res;
}
},
legend: { show: false },
series: [this.generateSery()]
};
},
enumerable: false,
configurable: true
});
RelationChartStore.prototype.generateSery = function () {
var _a = this.datas, layout = _a.layout, nodes = _a.nodes, links = _a.links;
var _b = this.chartStyleService, fillColor = _b.fillColor, curveness = _b.curveness;
var itemColor = _.get(this.themeOption, ['graph', 'itemStyle', 'color']);
var defaultColor = itemColor ? itemColor : this.themeOption.color[0];
var option = __assign(__assign({ type: 'graph', layout: layout, circular: {
rotateLabel: true
}, roam: true, edgeSymbol: ['none', 'arrow'], edgeSymbolSize: [6, 6], focusNodeAdjacency: true, data: nodes, links: links }, (fillColor ? { itemStyle: { color: fillColor } } : {})), { lineStyle: {
normal: {
color: fillColor ||
_.get(this.themeOption, ['graph', 'lineStyle', 'color']) ||
defaultColor,
curveness: curveness === undefined
? _.get(this.themeOption, ['graph', 'lineStyle', 'curveness'])
: curveness
}
}, cursor: this.chartCanClick ? 'pointer' : 'default' });
return option;
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationChartStore.prototype, "options", null);
return RelationChartStore;
}(RelationBaseChartStore));
export default RelationChartStore;