UNPKG

@rcsb/rcsb-saguaro

Version:
35 lines (34 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbAxisDisplay = void 0; const tslib_1 = require("tslib"); const RcsbAbstractDisplay_1 = require("./RcsbAbstractDisplay"); const d3_axis_1 = require("d3-axis"); const d3_format_1 = require("d3-format"); const classes = tslib_1.__importStar(require("../../scss/RcsbBoard.module.scss")); const RcsbD3Constants_1 = require("../RcsbD3/RcsbD3Constants"); class RcsbAxisDisplay extends RcsbAbstractDisplay_1.RcsbAbstractDisplay { constructor(boardId, trackId, length) { super(boardId, trackId); this.length = length; } reset() { super.reset(); this.g.selectAll(classes.tick).remove(); } ; update() { if (this.xAxis == null) { this.xAxis = (0, d3_axis_1.axisBottom)(this.xScale.getScale()); if (this.length != null && this.length < 9) this.xAxis.tickValues(Array(this.length).fill(0).map((v, i) => { return (i + 1); })).tickFormat((0, d3_format_1.format)("d")); this.g.classed(classes.rcsbAxis, true) .attr(RcsbD3Constants_1.RcsbD3Constants.TRANSFORM, "translate(0,10)") .call(this.xAxis); } } move() { this.g.call(this.xAxis); } } exports.RcsbAxisDisplay = RcsbAxisDisplay;