vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

  1. 'use strict';
  2. import NodeBase from '../util/NodeBase'
  3. class Database extends NodeBase {
  4. constructor (options, body, labelModule) {
  5. super(options, body, labelModule);
  6. this._setMargins(labelModule);
  7. }
  8. resize(ctx, selected, hover) {
  9. if (this.needsRefresh(selected, hover)) {
  10. this.textSize = this.labelModule.getTextSize(ctx, selected, hover);
  11. var size = this.textSize.width + this.margin.right + this.margin.left;
  12. this.width = size;
  13. this.height = size;
  14. this.radius = this.width / 2;
  15. }
  16. }
  17. draw(ctx, x, y, selected, hover, values) {
  18. this.resize(ctx, selected, hover);
  19. this.left = x - this.width / 2;
  20. this.top = y - this.height / 2;
  21. this.initContextForDraw(ctx, values);
  22. ctx.database(x - this.width / 2, y - this.height / 2, this.width, this.height);
  23. this.performFill(ctx, values);
  24. this.updateBoundingBox(x, y, ctx, selected, hover);
  25. this.labelModule.draw(ctx, this.left + this.textSize.width / 2 + this.margin.left,
  26. this.top + this.textSize.height / 2 + this.margin.top, selected, hover);
  27. }
  28. distanceToBorder(ctx, angle) {
  29. return this._distanceToBorder(ctx,angle);
  30. }
  31. }
  32. export default Database;