technology-chart
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -14,2 +14,5 @@ import { EventEmitter } from "../core/event-emitter"; | ||
private _currPointFocus; | ||
private _resizeHandler; | ||
private _moveHandler; | ||
private _clickHandler; | ||
constructor(canvas: any, settings: any); | ||
@@ -66,2 +69,8 @@ /** | ||
/** | ||
* Dispose chart. | ||
* | ||
* @memberof TechnologyChart | ||
*/ | ||
dispose(): void; | ||
/** | ||
* Prepare draw process. | ||
@@ -68,0 +77,0 @@ */ |
@@ -189,2 +189,16 @@ (function (global, factory) { | ||
}); | ||
Object.defineProperty(Point.prototype, "textColor", { | ||
/** | ||
* Get textColor of point. | ||
*/ | ||
get: function () { | ||
var _a, _b; | ||
if (this.marked) { | ||
return (_a = this._data.highlightTextColor) !== null && _a !== void 0 ? _a : this._attrs.layout.highlightTextColor; | ||
} | ||
return (_b = this._data.textColor) !== null && _b !== void 0 ? _b : this._attrs.layout.textColor; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
@@ -235,3 +249,3 @@ * Draw a point. | ||
context.beginPath(); | ||
context.fillStyle = this._attrs.layout.textColor; | ||
context.fillStyle = this.textColor; | ||
context.textAlign = "center"; | ||
@@ -593,2 +607,3 @@ context.textBaseline = "middle"; | ||
highlightBg: this._attrs.layout.point.highlightBg, | ||
highlightTextColor: this._attrs.layout.point.highlightTextColor, | ||
bg: this._attrs.layout.point.bg, | ||
@@ -623,3 +638,3 @@ textColor: this._attrs.layout.point.textColor, | ||
function validateSetting(setting) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z; | ||
if (!Array.isArray(setting.quadrants) || setting.quadrants.length === 0) { | ||
@@ -659,8 +674,9 @@ throw new Error("[Technology Chart] 'setting.quadrants' should exists and not be empty"); | ||
highlightBg: (_j = (_h = (_g = setting.layout) === null || _g === void 0 ? void 0 : _g.point) === null || _h === void 0 ? void 0 : _h.highlightBg) !== null && _j !== void 0 ? _j : "red", | ||
bg: (_m = (_l = (_k = setting.layout) === null || _k === void 0 ? void 0 : _k.point) === null || _l === void 0 ? void 0 : _l.bg) !== null && _m !== void 0 ? _m : "black", | ||
textColor: (_q = (_p = (_o = setting.layout) === null || _o === void 0 ? void 0 : _o.point) === null || _p === void 0 ? void 0 : _p.textColor) !== null && _q !== void 0 ? _q : "white", | ||
highlightTextColor: (_m = (_l = (_k = setting.layout) === null || _k === void 0 ? void 0 : _k.point) === null || _l === void 0 ? void 0 : _l.highlightTextColor) !== null && _m !== void 0 ? _m : "white", | ||
bg: (_q = (_p = (_o = setting.layout) === null || _o === void 0 ? void 0 : _o.point) === null || _p === void 0 ? void 0 : _p.bg) !== null && _q !== void 0 ? _q : "black", | ||
textColor: (_t = (_s = (_r = setting.layout) === null || _r === void 0 ? void 0 : _r.point) === null || _s === void 0 ? void 0 : _s.textColor) !== null && _t !== void 0 ? _t : "white", | ||
}, | ||
legend: { | ||
textColor: (_t = (_s = (_r = setting.layout) === null || _r === void 0 ? void 0 : _r.legend) === null || _s === void 0 ? void 0 : _s.textColor) !== null && _t !== void 0 ? _t : "#000", | ||
textSize: (_w = (_v = (_u = setting.layout) === null || _u === void 0 ? void 0 : _u.legend) === null || _v === void 0 ? void 0 : _v.textSize) !== null && _w !== void 0 ? _w : "11pt", | ||
textColor: (_w = (_v = (_u = setting.layout) === null || _u === void 0 ? void 0 : _u.legend) === null || _v === void 0 ? void 0 : _v.textColor) !== null && _w !== void 0 ? _w : "#000", | ||
textSize: (_z = (_y = (_x = setting.layout) === null || _x === void 0 ? void 0 : _x.legend) === null || _y === void 0 ? void 0 : _y.textSize) !== null && _z !== void 0 ? _z : "11pt", | ||
} | ||
@@ -840,2 +856,15 @@ } | ||
/** | ||
* Dispose chart. | ||
* | ||
* @memberof TechnologyChart | ||
*/ | ||
TechnologyChart.prototype.dispose = function () { | ||
this.context.clearRect(0, 0, this.size, this.size); | ||
if (typeof window !== "undefined") { | ||
window.removeEventListener("resize", this._resizeHandler); | ||
} | ||
this._canvas.removeEventListener("click", this._clickHandler); | ||
this._canvas.removeEventListener("mousemove", this._moveHandler); | ||
}; | ||
/** | ||
* Prepare draw process. | ||
@@ -880,2 +909,3 @@ */ | ||
highlightBg: this._settings.layout.point.highlightBg, | ||
highlightTextColor: this._settings.layout.point.highlightTextColor, | ||
bg: this._settings.layout.point.bg, | ||
@@ -914,13 +944,15 @@ textColor: this._settings.layout.point.textColor, | ||
var _this = this; | ||
this._resizeHandler = function () { | ||
_this.draw(true); | ||
}; | ||
if (typeof window !== 'undefined') { | ||
window.addEventListener("resize", function () { | ||
_this.draw(true); | ||
}); | ||
window.addEventListener("resize", this._resizeHandler); | ||
} | ||
this._canvas.addEventListener("click", function () { | ||
this._clickHandler = function () { | ||
if (_this._currPointFocus != null) { | ||
_this.emit("pointclick", _this._currPointFocus); | ||
} | ||
}); | ||
this._canvas.addEventListener("mousemove", function (e) { | ||
}; | ||
this._canvas.addEventListener("click", this._clickHandler); | ||
this._moveHandler = function (e) { | ||
var _a; | ||
@@ -956,3 +988,4 @@ if (typeof window !== "undefined") { | ||
} | ||
}); | ||
}; | ||
this._canvas.addEventListener("mousemove", this._moveHandler); | ||
}; | ||
@@ -959,0 +992,0 @@ return TechnologyChart; |
@@ -45,2 +45,6 @@ import { IPointAttributes } from "../types/point"; | ||
/** | ||
* Get textColor of point. | ||
*/ | ||
get textColor(): string; | ||
/** | ||
* Draw a point. | ||
@@ -47,0 +51,0 @@ */ |
@@ -26,2 +26,3 @@ import { IVector } from "./position"; | ||
highlightBg: string; | ||
highlightTextColor: string; | ||
bg: string; | ||
@@ -28,0 +29,0 @@ textColor: string; |
@@ -27,2 +27,3 @@ import { IVector } from "./position"; | ||
highlightBg: string; | ||
highlightTextColor: string; | ||
bg: string; | ||
@@ -29,0 +30,0 @@ textColor: string; |
@@ -19,2 +19,3 @@ /** | ||
highlightBg?: string; | ||
highlightTextColor?: string; | ||
bg?: string; | ||
@@ -37,3 +38,5 @@ textColor?: string; | ||
highlightBg?: string; | ||
textColor?: string; | ||
highlightTextColor?: string; | ||
index?: number; | ||
} |
{ | ||
"name": "technology-chart", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Vanilla library for create technology radar chart using canvas API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.min.js", |
52934
1413