Skip to content

Commit

Permalink
fix(stats): Interactive RED plots now are within margins and display …
Browse files Browse the repository at this point in the history
…Order plus count on Y axis.
  • Loading branch information
aaronmussig committed Mar 28, 2022
1 parent d8366ec commit 6d8eb78
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 10 deletions.
4 changes: 2 additions & 2 deletions assets/data/stats/r202/red-archaea.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"width": 1152.0,
"height": 576.0,
"width": 900,
"height": 460,
"axes": [
{
"bbox": [
Expand Down
4 changes: 2 additions & 2 deletions assets/data/stats/r89/r89-red-archaea.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"width": 921.6,
"height": 460.8,
"width": 900,
"height": 460,
"axes": [
{
"bbox": [
Expand Down
4 changes: 2 additions & 2 deletions assets/data/stats/r89/r89-red-bacteria.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"width": 921.6,
"height": 460.8,
"width": 900,
"height": 460,
"axes": [
{
"bbox": [
Expand Down
4 changes: 2 additions & 2 deletions assets/data/stats/r95/red-archaea.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"width": 921.6,
"height": 460.8,
"width": 900,
"height": 460,
"axes": [
{
"bbox": [
Expand Down
4 changes: 2 additions & 2 deletions assets/data/stats/r95/red-bacteria.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"width": 921.6,
"height": 460.8,
"width": 900,
"height": 460,
"axes": [
{
"bbox": [
Expand Down
23 changes: 23 additions & 0 deletions components/stats/REDr202.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ const bacteria = require('~/assets/data/stats/r202/red-bacteria.json')
export default Vue.extend({
mounted() {
mpld3.register_plugin("axisreplacer", AxisReplacer);
AxisReplacer.prototype = Object.create(mpld3.Plugin.prototype);
AxisReplacer.prototype.constructor = AxisReplacer;
AxisReplacer.prototype.requiredProps = ["data"];
AxisReplacer.prototype.defaultProps = {}
// @ts-ignore
function AxisReplacer(fig, props){
// @ts-ignore
mpld3.Plugin.call(this, fig, props);
}
AxisReplacer.prototype.draw = function(){
let data = this.props.data;
let parent = document.getElementsByClassName("mpld3-yaxis")[0];
let gTicks = parent.getElementsByTagName("g");
for (let i=0; i < gTicks.length; i++) {
let curTick = gTicks[i];
let curText = curTick.getElementsByTagName("text")[0];
curText.innerHTML = data[i];
}
};
mpld3.draw_figure("fig_el729391400845065580326015787637", archaea);
mpld3.draw_figure("fig_el730431405688597008165473308651", bacteria);
}
Expand Down
23 changes: 23 additions & 0 deletions components/stats/REDr89.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ const bacteria = require('~/assets/data/stats/r89/r89-red-bacteria.json')
export default Vue.extend({
mounted() {
mpld3.register_plugin("axisreplacer", AxisReplacer);
AxisReplacer.prototype = Object.create(mpld3.Plugin.prototype);
AxisReplacer.prototype.constructor = AxisReplacer;
AxisReplacer.prototype.requiredProps = ["data"];
AxisReplacer.prototype.defaultProps = {}
// @ts-ignore
function AxisReplacer(fig, props){
// @ts-ignore
mpld3.Plugin.call(this, fig, props);
}
AxisReplacer.prototype.draw = function(){
let data = this.props.data;
let parent = document.getElementsByClassName("mpld3-yaxis")[0];
let gTicks = parent.getElementsByTagName("g");
for (let i=0; i < gTicks.length; i++) {
let curTick = gTicks[i];
let curText = curTick.getElementsByTagName("text")[0];
curText.innerHTML = data[i];
}
};
mpld3.draw_figure("fig_el28851405150924847282779648570", archaea);
mpld3.draw_figure("fig_el28581405953535391925487034777", bacteria);
}
Expand Down
23 changes: 23 additions & 0 deletions components/stats/REDr95.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@ const bacteria = require('~/assets/data/stats/r95/red-bacteria.json')
export default Vue.extend({
mounted() {
mpld3.register_plugin("axisreplacer", AxisReplacer);
AxisReplacer.prototype = Object.create(mpld3.Plugin.prototype);
AxisReplacer.prototype.constructor = AxisReplacer;
AxisReplacer.prototype.requiredProps = ["data"];
AxisReplacer.prototype.defaultProps = {}
// @ts-ignore
function AxisReplacer(fig, props){
// @ts-ignore
mpld3.Plugin.call(this, fig, props);
}
AxisReplacer.prototype.draw = function(){
let data = this.props.data;
let parent = document.getElementsByClassName("mpld3-yaxis")[0];
let gTicks = parent.getElementsByTagName("g");
for (let i=0; i < gTicks.length; i++) {
let curTick = gTicks[i];
let curText = curTick.getElementsByTagName("text")[0];
curText.innerHTML = data[i];
}
};
mpld3.draw_figure("fig_el1832140480597119608954246934", archaea);
mpld3.draw_figure("fig_el19001406310551926967170213038", bacteria);
}
Expand Down

0 comments on commit 6d8eb78

Please sign in to comment.