删除UI中Svg代码。

This commit is contained in:
liteng 2018-11-04 21:04:08 +08:00
parent b53f14b5c9
commit b048b2eb28
10 changed files with 0 additions and 338 deletions

View File

@ -1,57 +0,0 @@
import Control from '../Control';
/**
* SvgDom
* @author tengge / https://github.com/tengge1
*/
function SvgDom(options) {
Control.call(this, options);
options = options || {};
this.width = options.width || 960;
this.height = options.height || 500;
this.children = [];
}
SvgDom.prototype = Object.create(Control.prototype);
SvgDom.prototype.constructor = SvgDom;
SvgDom.prototype.add = function (element) {
this.children.push(element);
};
SvgDom.prototype.insert = function (index, element) {
this.children.splice(index, 0, element);
};
SvgDom.prototype.remove = function (element) {
var index = this.children.indexOf(element);
if (index > -1) {
this.removeAt(index);
}
};
SvgDom.prototype.removeAt = function (index) {
this.children.splice(index, 1);
};
SvgDom.prototype.removeAll = function () {
this.children = [];
};
SvgDom.prototype.clear = function () {
this.removeAll();
};
SvgDom.prototype.render = function () {
this.el = this.parent.append('svg')
.attr('width', this.width)
.attr('height', this.height);
var _this = this;
this.children.forEach(function (n) {
n.parent = _this.el;
n.render.call(n);
});
};
export default SvgDom;

View File

@ -1,54 +0,0 @@
import { SvgElement } from './element/SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgGroup(options) {
SvgElement.call(this, options);
options = options || {};
this.fill = options.fill || null;
this.children = [];
}
SvgGroup.prototype = Object.create(SvgElement.prototype);
SvgGroup.prototype.constructor = SvgGroup;
SvgGroup.prototype.add = function(element) {
this.children.push(element);
};
SvgGroup.prototype.insert = function(index, element) {
this.children.splice(index, 0, element);
};
SvgGroup.prototype.remove = function(element) {
var index = this.children.indexOf(element);
if (index > -1) {
this.removeAt(index);
}
};
SvgGroup.prototype.removeAt = function(index) {
this.children.splice(index, 1);
};
SvgGroup.prototype.removeAll = function() {
this.children = [];
};
SvgGroup.prototype.clear = function() {
this.removeAll();
};
SvgGroup.prototype.render = function() {
this.el = this.parent.append('g')
.call(this.renderStyle, this);
var _this = this;
this.children.forEach(function(n) {
n.parent = _this.el;
n.render.call(n);
});
};
export { SvgGroup };

View File

@ -1,26 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgCircle(options) {
SvgElement.call(this, options);
options = options || {};
this.cx = options.cx || null;
this.cy = options.cy || null;
this.r = options.r || 50;
}
SvgCircle.prototype = Object.create(SvgElement.prototype);
SvgCircle.prototype.constructor = SvgCircle;
SvgCircle.prototype.render = function() {
this.parent.append('circle')
.attr('cx', this.cx)
.attr('cy', this.cy)
.attr('r', this.r)
.call(this.renderStyle, this);
};
export { SvgCircle };

View File

@ -1,36 +0,0 @@
/**
* @author tengge / https://github.com/tengge1
*/
function SvgElement(options) {
options = options || [];
this.parent = d3.select(options.parent || document.body);
this.stroke = options.stroke || null;
this.strokeWidth = options.strokeWidth || null;
this.strokeOpacity = options.strokeOpacity || null;
this.strokeLinecap = options.strokeLinecap || null; // butt, square, round
this.fill = options.fill || null;
this.fillOpacity = options.fillOpacity || null;
this.fillRule = options.fillRule || null; // nonzero, evenodd
this.opacity = options.opacity || null;
this.style = options.style || null;
}
SvgElement.prototype.render = function() {
};
SvgElement.prototype.renderStyle = function(selection, scope) {
return selection
.attr('stroke', scope.stroke)
.attr('stroke-width', scope.strokeWidth)
.attr('stroke-opacity', scope.strokeOpacity)
.attr('stroke-linecap', scope.strokeLinecap)
.attr('fill', scope.fill)
.attr('fill-opacity', scope.fillOpacity)
.attr('fill-rule', scope.fillRule)
.attr('opacity', scope.opacity)
.attr('style', scope.style);
};
export { SvgElement };

View File

@ -1,28 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgEllipse(options) {
SvgElement.call(this, options);
options = options || {};
this.cx = options.cx || null;
this.cy = options.cy || null;
this.rx = options.rx || 100;
this.ry = options.ry || 60;
}
SvgEllipse.prototype = Object.create(SvgElement.prototype);
SvgEllipse.prototype.constructor = SvgEllipse;
SvgEllipse.prototype.render = function() {
this.parent.append('ellipse')
.attr('cx', this.cx)
.attr('cy', this.cy)
.attr('rx', this.rx)
.attr('ry', this.ry)
.call(this.renderStyle, this);
};
export { SvgEllipse };

View File

@ -1,30 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgLine(options) {
SvgElement.call(this, options);
options = options || {};
this.x1 = options.x1 || 0;
this.y1 = options.y1 || 0;
this.x2 = options.x2 || 100;
this.y2 = options.y2 || 100;
this.stroke = options.stroke === undefined ? 'red' : options.stroke;
this.strokeWidth = options.strokeWidth || 2;
}
SvgLine.prototype = Object.create(SvgElement.prototype);
SvgLine.prototype.constructor = SvgLine;
SvgLine.prototype.render = function() {
this.parent.append('line')
.attr('x1', this.x1)
.attr('y1', this.y1)
.attr('x2', this.x2)
.attr('y2', this.y2)
.call(this.renderStyle, this);
};
export { SvgLine };

View File

@ -1,25 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgPath(options) {
SvgElement.call(this, options);
options = options || {};
this.d = options.d || 'M0 0 L100 0 L100 100 Z'; // M, L, H, V, C, S, Q, T, A, Z
this.stroke = options.stroke || 'red';
this.strokeWidth = options.strokeWidth || 2;
this.fill = options.fill || 'none';
}
SvgPath.prototype = Object.create(SvgElement.prototype);
SvgPath.prototype.constructor = SvgPath;
SvgPath.prototype.render = function() {
this.parent.append('path')
.attr('d', this.d)
.call(this.renderStyle, this);
};
export { SvgPath };

View File

@ -1,25 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgPolygon(options) {
SvgElement.call(this, options);
options = options || {};
this.points = options.points || '0,0,100,0,100,100,0,100';
this.stroke = options.stroke || 'red';
this.strokeWidth = options.strokeWidth || 2;
this.fill = options.fill || 'yellow';
}
SvgPolygon.prototype = Object.create(SvgElement.prototype);
SvgPolygon.prototype.constructor = SvgPolygon;
SvgPolygon.prototype.render = function() {
this.parent.append('polygon')
.attr('points', this.points)
.call(this.renderStyle, this);
};
export { SvgPolygon };

View File

@ -1,25 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgPolyline(options) {
SvgElement.call(this, options);
options = options || {};
this.points = options.points || '0,0,100,100,150,100,150,150';
this.stroke = options.stroke === undefined ? 'red' : options.stroke;
this.strokeWidth = options.strokeWidth || 2;
this.fill = options.fill || 'none';
}
SvgPolyline.prototype = Object.create(SvgElement.prototype);
SvgPolyline.prototype.constructor = SvgPolyline;
SvgPolyline.prototype.render = function() {
this.parent.append('polyline')
.attr('points', this.points)
.call(this.renderStyle, this);
};
export { SvgPolyline };

View File

@ -1,32 +0,0 @@
import { SvgElement } from './SvgElement';
/**
* @author tengge / https://github.com/tengge1
*/
function SvgRect(options) {
SvgElement.call(this, options);
options = options || {};
this.x = options.x || null;
this.y = options.y || null;
this.width = options.width || 100;
this.height = options.height || 60;
this.rx = options.rx || null;
this.ry = options.ry || null;
}
SvgRect.prototype = Object.create(SvgElement.prototype);
SvgRect.prototype.constructor = SvgRect;
SvgRect.prototype.render = function() {
this.parent.append('rect')
.attr('x', this.x)
.attr('y', this.y)
.attr('width', this.width)
.attr('height', this.height)
.attr('rx', this.rx)
.attr('ry', this.ry)
.call(this.renderStyle, this);
};
export { SvgRect };