@inb/oeb_visualizations 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,14 @@
1
1
  # OpenEBench Visualizations
2
2
 
3
- Collection of Vue components for data visualization in OpenEBench.
3
+ Collection of Vue components for data visualization in OpenEBench.
4
+
5
+ - Go to the [demo](https://inab.github.io/oeb-visualizations-demo/) to see the components in action.
6
+ - This package is available through [npmjs](https://www.npmjs.com/package/@inb/oeb-visualizations).
7
+
8
+ ## Installation
9
+
10
+ To install the package run:
11
+
12
+ ```bash
13
+ npm install @inb/oeb-visualizations
14
+ ```
@@ -1 +1 @@
1
- function normalizeComponent(e,t,r,a,n,i,o,s,l,u){"boolean"!=typeof o&&(l=s,s=o,o=!1);var c="function"==typeof r?r.options:r;e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,n&&(c.functional=!0)),a&&(c._scopeId=a);var _;if(i?(_=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},c._ssrRegister=_):t&&(_=o?function(){t.call(this,u(this.$root.$options.shadowRoot))}:function(e){t.call(this,s(e))}),_)if(c.functional){var d=c.render;c.render=function(e,t){return _.call(t),d(e,t)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,_):[_]}return r}import Plotly from"plotly.js-dist";for(var moment=require("moment"),dates=[],i=0;i<30;i++){var date=moment().add(i,"days").format("YYYY-MM-DD");dates.push(date)}dates.sort(function(e,t){return e.localeCompare(t)}),console.log(dates);for(var numbers=[],status=[],i$1=0;i$1<30;i$1++){var number=Math.floor(81*Math.random())+20;number>30&&number<90?status.push("up"):number>=90?(status.push("NA"),number=null):(status.push("down"),number=null),numbers.push(number)}var data={date:dates,uptime:numbers,status:status},script={name:"accessibilityPlot",mounted:function(){var e=this.buildTimeTraces(data);e=e.concat(this.buildBarTraces(data));var t=data.uptime.filter(function(e){return null!==e}),r=t.reduce(function(e,t){return e+t},0)/t.length,a=new Date(data.date[0]);a.setDate(a.getDate()-1);var n=new Date(data.date[data.date.length-1]);n.setDate(n.getDate()+1),console.log(r);var i={x:[a,n],y:[r,r],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba(111, 176, 129,.6)",width:1.5,dash:"4px"},marker:{size:5}};e.push(i);var o={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:400,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:Math.min(data.x),dtick:2592e5,tickangle:45,tickformat:"%d %b",ticklabelmode:"period"},yaxis:{title:"Access time (ms)",titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}}};Plotly.newPlot("plot",e,o)},methods:{generateColor:function(e,t){for(var r=[],a=0;a<30;a++)switch(e[a]){case"up":r.push("rgba(218, 247, 223,0)");break;case"down":r.push("rgba(255, 153, 145,"+t+")");break;case"NA":r.push("rgba(204,204,204,"+t+")")}return console.log(r),r},extractSubarraysBetweenNullValues:function(e){for(var t=[],r=[],a=[],n=[],i=0;i<e.uptime.length;i++)null===e.uptime[i]?a.length>0&&(t.push(a),r.push(n),a=[],n=[]):(a.push(e.uptime[i]),n.push(e.date[i]));return a.length>0&&(t.push(a),r.push(n)),{uptime:t,date:r}},buildTimeTraces:function(e){for(var t=this.extractSubarraysBetweenNullValues(e),r=[],a=0;a<t.uptime.length;a++){var n=t.uptime[a],i={x:t.date[a],y:n,name:"Online",legendgroup:"up",showlegend:0===a,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba(218, 247, 223,.4)",connectgaps:!1,line:{color:"rgba(111, 176, 129,.8)",width:1.5},marker:{size:5}};r.push(i)}return r},extractSubarraysOfNullValues:function(e,t){for(var r=[],a=0;a<e.uptime.length;a++)null===e.uptime[a]&&e.status[a]===t&&r.push(e.date[a]);return r},buildBarTraces:function(e){var t=[],r=this.extractSubarraysOfNullValues(e,"down");console.log(r);var a=Array(r.length).fill(2).concat(Array(r.length).fill(120)),n=Array(r.length).fill("rgba(255, 153, 145,.8)").concat(Array(r.length).fill("rgba(255, 153, 145,.2)"));r=r.concat(r);var i=this.extractSubarraysOfNullValues(e,"NA"),o=Array(i.length).fill(2).concat(Array(i.length).fill(120)),s=Array(i.length).fill("rgba(204,204,204,.8)").concat(Array(i.length).fill("rgba(204,204,204,.2)"));i=i.concat(i);var l={x:r,y:a,marker:{color:n},name:"Offline",type:"bar"};t.push(l);var u={x:i,y:o,marker:{color:s},name:"No information captured",type:"bar"};return t.push(u),t}}},normalizeComponent_1=normalizeComponent,__vue_script__=script,__vue_render__=function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plot"}})},__vue_staticRenderFns__=[],__vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1,accessibilityPlot=normalizeComponent_1({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},__vue_inject_styles__,__vue_script__,__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,void 0,void 0);export{accessibilityPlot};
1
+ function normalizeComponent(e,t,i,r,a,s,n,o,l,c){"boolean"!=typeof n&&(l=o,o=n,n=!1);var d="function"==typeof i?i.options:i;e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,a&&(d.functional=!0)),r&&(d._scopeId=r);var u;if(s?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=u):t&&(u=n?function(){t.call(this,c(this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),u)if(d.functional){var _=d.render;d.render=function(e,t){return u.call(t),_(e,t)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,u):[u]}return i}import Plotly from"plotly.js-dist";var script={name:"accessibilityPlot",props:{dtick:{type:Number,required:!1,default:864e5},xaxisTitle:{type:String,required:!1,default:"Date"},yaxisTitle:{type:String,required:!1,default:"Access time (ms)"},colorOnline:{type:String,required:!1,default:"111, 176, 129"},colorOffline:{type:String,required:!1,default:"255, 153, 145"},colorNA:{type:String,required:!1,default:"204,204,204"},height:{type:Number,required:!1,default:400},dataItems:{type:Array,required:!0,validator:function(e){for(var t=0;t<e.length;t++)e[t].hasOwnProperty("access_time")?e[t].hasOwnProperty("date")?e[t].hasOwnProperty("code")||console.error("[oeb-visualizations warn] code key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] date key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] access_time key is missing in dataItems prop item (at position "+t+")"),null!==e[t].access_time&&"number"!=typeof e[t].access_time&&console.error("[oeb-visualizations warn] access_time must be null or a number in dataItems prop item (at position "+t+")"),null!==e[t].code&&"number"!=typeof e[t].code&&console.error("[oeb-visualizations warn] code must be null or a number in dataItems prop item (at position "+t+")"),("string"!=typeof e[t].date||isNaN(Date.parse(e[t].date)))&&console.error("[oeb-visualizations warn] date must be a string containing a date in dataItems prop item (at position "+t+")"),null===e[t].date&&console.error("[oeb-visualizations warn] date cannot be null in dataItems prop item (at position "+t+")");return!0}}},mounted:function(){var e=this.buildOnlineTraces(this.dataItems);e=e.concat(this.buildOfflineNATraces(this.dataItems));var t={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:this.height,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",title:this.xaxisTitle,font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:this.dataItems[0].date,dtick:this.dtick,tickangle:45,tickformat:"%d %b"},yaxis:{title:this.yaxisTitle,titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}},hoverlabel:{bgcolor:"#FFF"},hovermode:"closest",hoverdistance:70};Plotly.newPlot("plotAccessibility",e,t)},methods:{generateColor:function(e,t){for(var i=[],r=0;r<30;r++)switch(e[r]){case"up":i.push("rgba("+this.colorOnline+",0)");break;case"down":i.push("rgba("+this.colorOffline+","+t+")");break;case"NA":i.push("rgba("+this.colorNA+","+t+")")}return i},extractSubarraysBetweenNullValues:function(e){for(var t={access_time:[],date:[],average_access_time:0},i=[],r=[],a=0,s=0,n=0;n<e.length;n++)null!==e[n].access_time?(i.push(e[n].access_time),r.push(e[n].date),a+=e[n].access_time,s+=1):i.length>0&&(t.access_time.push(i),t.date.push(r),i=[],r=[]);return t.access_time.push(i),t.date.push(r),t.average_access_time=a/s,t},buildAccessTimeTraces:function(e){for(var t=[],i=0;i<e.access_time.length;i++){var r=e.access_time[i],a={x:e.date[i],y:r,name:"Online",legendgroup:"up",showlegend:0===i,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba("+this.colorOnline+",.2)",connectgaps:!1,line:{color:"rgba("+this.colorOnline+",.8)",width:1.5},marker:{size:5},hovertemplate:"<b>Online</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>",hoveron:"points+fills"};t.push(a)}return t},buildAvgAccessTimeTrace:function(e){var t=new Date(this.dataItems[0].date);t.setDate(t.getDate()-1);var i=new Date(this.dataItems[this.dataItems.length-1].date);return i.setDate(i.getDate()+1),{x:[t,i],y:[e,e],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba("+this.colorOnline+",.6)",width:1.5,dash:"4px"},marker:{size:5}}},buildOnlineTraces:function(e){var t=this.extractSubarraysBetweenNullValues(e),i=this.buildAccessTimeTraces(t);return i.push(this.buildAvgAccessTimeTrace(t.average_access_time)),i},extractOfflineNADates:function(e){for(var t=[404,500,502,503,504],i=[],r=[],a=0;a<e.length;a++)null===e[a].access_time&&null===e[a].code?i.push(e[a].date):null===e[a].access_time&&t.includes(e[a].code)&&r.push(e[a].date);return{NA:i,down:r}},barTrace:function(e,t,i,r,a){return{x:e.dates,y:e.access_times,marker:{color:e.colors},name:t,type:"bar",legendgroup:"down",showlegend:i,hoverinfo:r,hovertemplate:a}},buildBarTraces:function(e,t,i){var r="rgba("+t+",.8)",a="rgba("+t+",.2)",s={dates:e,access_times:Array(e.length).fill(2),colors:Array(e.length).fill(r)},n={dates:e,access_times:Array(e.length).fill(120),colors:Array(e.length).fill(a)},o="<b>"+i+"</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>";return[this.barTrace(s,i,!1,"skip",""),this.barTrace(n,i,!0,"all",o)]},buildOfflineNATraces:function(e){var t=[],i=this.extractOfflineNADates(e);return t=t.concat(this.buildBarTraces(i.down,this.colorOffline,"Offline")),t=t.concat(this.buildBarTraces(i.NA,this.colorNA,"No information available"))}}},normalizeComponent_1=normalizeComponent,__vue_script__=script,__vue_render__=function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plotAccessibility"}})},__vue_staticRenderFns__=[],__vue_inject_styles__=void 0,__vue_scope_id__=void 0,__vue_module_identifier__=void 0,__vue_is_functional_template__=!1,accessibilityPlot=normalizeComponent_1({render:__vue_render__,staticRenderFns:__vue_staticRenderFns__},__vue_inject_styles__,__vue_script__,__vue_scope_id__,__vue_is_functional_template__,__vue_module_identifier__,void 0,void 0);export{accessibilityPlot};
@@ -1 +1 @@
1
- var oeb_visualizations=function(e,t){"use strict";function r(e,t,r,a,n,o,i,l,s,u){"boolean"!=typeof i&&(s=l,l=i,i=!1);var c="function"==typeof r?r.options:r;e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,n&&(c.functional=!0)),a&&(c._scopeId=a);var d;if(o?(d=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,s(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=d):t&&(d=i?function(){t.call(this,u(this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),d)if(c.functional){var h=c.render;c.render=function(e,t){return d.call(t),h(e,t)}}else{var p=c.beforeCreate;c.beforeCreate=p?[].concat(p,d):[d]}return r}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;for(var a=require("moment"),n=[],o=0;o<30;o++){var i=a().add(o,"days").format("YYYY-MM-DD");n.push(i)}n.sort(function(e,t){return e.localeCompare(t)}),console.log(n);for(var l=[],s=[],u=0;u<30;u++){var c=Math.floor(81*Math.random())+20;c>30&&c<90?s.push("up"):c>=90?(s.push("NA"),c=null):(s.push("down"),c=null),l.push(c)}var d={date:n,uptime:l,status:s},h=r({render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plot"}})},staticRenderFns:[]},void 0,{name:"accessibilityPlot",mounted:function(){var e=this.buildTimeTraces(d);e=e.concat(this.buildBarTraces(d));var r=d.uptime.filter(function(e){return null!==e}),a=r.reduce(function(e,t){return e+t},0)/r.length,n=new Date(d.date[0]);n.setDate(n.getDate()-1);var o=new Date(d.date[d.date.length-1]);o.setDate(o.getDate()+1),console.log(a);var i={x:[n,o],y:[a,a],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba(111, 176, 129,.6)",width:1.5,dash:"4px"},marker:{size:5}};e.push(i);var l={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:400,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:Math.min(d.x),dtick:2592e5,tickangle:45,tickformat:"%d %b",ticklabelmode:"period"},yaxis:{title:"Access time (ms)",titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}}};t.newPlot("plot",e,l)},methods:{generateColor:function(e,t){for(var r=[],a=0;a<30;a++)switch(e[a]){case"up":r.push("rgba(218, 247, 223,0)");break;case"down":r.push("rgba(255, 153, 145,"+t+")");break;case"NA":r.push("rgba(204,204,204,"+t+")")}return console.log(r),r},extractSubarraysBetweenNullValues:function(e){for(var t=[],r=[],a=[],n=[],o=0;o<e.uptime.length;o++)null===e.uptime[o]?a.length>0&&(t.push(a),r.push(n),a=[],n=[]):(a.push(e.uptime[o]),n.push(e.date[o]));return a.length>0&&(t.push(a),r.push(n)),{uptime:t,date:r}},buildTimeTraces:function(e){for(var t=this.extractSubarraysBetweenNullValues(e),r=[],a=0;a<t.uptime.length;a++){var n=t.uptime[a],o={x:t.date[a],y:n,name:"Online",legendgroup:"up",showlegend:0===a,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba(218, 247, 223,.4)",connectgaps:!1,line:{color:"rgba(111, 176, 129,.8)",width:1.5},marker:{size:5}};r.push(o)}return r},extractSubarraysOfNullValues:function(e,t){for(var r=[],a=0;a<e.uptime.length;a++)null===e.uptime[a]&&e.status[a]===t&&r.push(e.date[a]);return r},buildBarTraces:function(e){var t=[],r=this.extractSubarraysOfNullValues(e,"down");console.log(r);var a=Array(r.length).fill(2).concat(Array(r.length).fill(120)),n=Array(r.length).fill("rgba(255, 153, 145,.8)").concat(Array(r.length).fill("rgba(255, 153, 145,.2)"));r=r.concat(r);var o=this.extractSubarraysOfNullValues(e,"NA"),i=Array(o.length).fill(2).concat(Array(o.length).fill(120)),l=Array(o.length).fill("rgba(204,204,204,.8)").concat(Array(o.length).fill("rgba(204,204,204,.2)"));o=o.concat(o);var s={x:r,y:a,marker:{color:n},name:"Offline",type:"bar"};t.push(s);var u={x:o,y:i,marker:{color:l},name:"No information captured",type:"bar"};return t.push(u),t}}},void 0,!1,void 0,void 0,void 0);return e.accessibilityPlot=h,e}({},Plotly);
1
+ var oeb_visualizations=function(e,t){"use strict";function i(e,t,i,a,r,s,n,o,l,c){"boolean"!=typeof n&&(l=o,o=n,n=!1);var d="function"==typeof i?i.options:i;e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,r&&(d.functional=!0)),a&&(d._scopeId=a);var u;if(s?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=u):t&&(u=n?function(){t.call(this,c(this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),u)if(d.functional){var h=d.render;d.render=function(e,t){return u.call(t),h(e,t)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,u):[u]}return i}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var a=i({render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plotAccessibility"}})},staticRenderFns:[]},void 0,{name:"accessibilityPlot",props:{dtick:{type:Number,required:!1,default:864e5},xaxisTitle:{type:String,required:!1,default:"Date"},yaxisTitle:{type:String,required:!1,default:"Access time (ms)"},colorOnline:{type:String,required:!1,default:"111, 176, 129"},colorOffline:{type:String,required:!1,default:"255, 153, 145"},colorNA:{type:String,required:!1,default:"204,204,204"},height:{type:Number,required:!1,default:400},dataItems:{type:Array,required:!0,validator:function(e){for(var t=0;t<e.length;t++)e[t].hasOwnProperty("access_time")?e[t].hasOwnProperty("date")?e[t].hasOwnProperty("code")||console.error("[oeb-visualizations warn] code key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] date key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] access_time key is missing in dataItems prop item (at position "+t+")"),null!==e[t].access_time&&"number"!=typeof e[t].access_time&&console.error("[oeb-visualizations warn] access_time must be null or a number in dataItems prop item (at position "+t+")"),null!==e[t].code&&"number"!=typeof e[t].code&&console.error("[oeb-visualizations warn] code must be null or a number in dataItems prop item (at position "+t+")"),("string"!=typeof e[t].date||isNaN(Date.parse(e[t].date)))&&console.error("[oeb-visualizations warn] date must be a string containing a date in dataItems prop item (at position "+t+")"),null===e[t].date&&console.error("[oeb-visualizations warn] date cannot be null in dataItems prop item (at position "+t+")");return!0}}},mounted:function(){var e=this.buildOnlineTraces(this.dataItems);e=e.concat(this.buildOfflineNATraces(this.dataItems));var i={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:this.height,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",title:this.xaxisTitle,font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:this.dataItems[0].date,dtick:this.dtick,tickangle:45,tickformat:"%d %b"},yaxis:{title:this.yaxisTitle,titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}},hoverlabel:{bgcolor:"#FFF"},hovermode:"closest",hoverdistance:70};t.newPlot("plotAccessibility",e,i)},methods:{generateColor:function(e,t){for(var i=[],a=0;a<30;a++)switch(e[a]){case"up":i.push("rgba("+this.colorOnline+",0)");break;case"down":i.push("rgba("+this.colorOffline+","+t+")");break;case"NA":i.push("rgba("+this.colorNA+","+t+")")}return i},extractSubarraysBetweenNullValues:function(e){for(var t={access_time:[],date:[],average_access_time:0},i=[],a=[],r=0,s=0,n=0;n<e.length;n++)null!==e[n].access_time?(i.push(e[n].access_time),a.push(e[n].date),r+=e[n].access_time,s+=1):i.length>0&&(t.access_time.push(i),t.date.push(a),i=[],a=[]);return t.access_time.push(i),t.date.push(a),t.average_access_time=r/s,t},buildAccessTimeTraces:function(e){for(var t=[],i=0;i<e.access_time.length;i++){var a=e.access_time[i],r={x:e.date[i],y:a,name:"Online",legendgroup:"up",showlegend:0===i,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba("+this.colorOnline+",.2)",connectgaps:!1,line:{color:"rgba("+this.colorOnline+",.8)",width:1.5},marker:{size:5},hovertemplate:"<b>Online</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>",hoveron:"points+fills"};t.push(r)}return t},buildAvgAccessTimeTrace:function(e){var t=new Date(this.dataItems[0].date);t.setDate(t.getDate()-1);var i=new Date(this.dataItems[this.dataItems.length-1].date);return i.setDate(i.getDate()+1),{x:[t,i],y:[e,e],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba("+this.colorOnline+",.6)",width:1.5,dash:"4px"},marker:{size:5}}},buildOnlineTraces:function(e){var t=this.extractSubarraysBetweenNullValues(e),i=this.buildAccessTimeTraces(t);return i.push(this.buildAvgAccessTimeTrace(t.average_access_time)),i},extractOfflineNADates:function(e){for(var t=[404,500,502,503,504],i=[],a=[],r=0;r<e.length;r++)null===e[r].access_time&&null===e[r].code?i.push(e[r].date):null===e[r].access_time&&t.includes(e[r].code)&&a.push(e[r].date);return{NA:i,down:a}},barTrace:function(e,t,i,a,r){return{x:e.dates,y:e.access_times,marker:{color:e.colors},name:t,type:"bar",legendgroup:"down",showlegend:i,hoverinfo:a,hovertemplate:r}},buildBarTraces:function(e,t,i){var a="rgba("+t+",.8)",r="rgba("+t+",.2)",s={dates:e,access_times:Array(e.length).fill(2),colors:Array(e.length).fill(a)},n={dates:e,access_times:Array(e.length).fill(120),colors:Array(e.length).fill(r)},o="<b>"+i+"</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>";return[this.barTrace(s,i,!1,"skip",""),this.barTrace(n,i,!0,"all",o)]},buildOfflineNATraces:function(e){var t=[],i=this.extractOfflineNADates(e);return t=t.concat(this.buildBarTraces(i.down,this.colorOffline,"Offline")),t=t.concat(this.buildBarTraces(i.NA,this.colorNA,"No information available"))}}},void 0,!1,void 0,void 0,void 0);return e.accessibilityPlot=a,e}({},Plotly);
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("plotly.js-dist")):"function"==typeof define&&define.amd?define(["exports","plotly.js-dist"],t):(e=e||self,t(e.oeb_visualizations={},e.Plotly))}(this,function(e,t){"use strict";function r(e,t,r,a,n,o,i,l,s,u){"boolean"!=typeof i&&(s=l,l=i,i=!1);var c="function"==typeof r?r.options:r;e&&e.render&&(c.render=e.render,c.staticRenderFns=e.staticRenderFns,c._compiled=!0,n&&(c.functional=!0)),a&&(c._scopeId=a);var d;if(o?(d=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,s(e)),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=d):t&&(d=i?function(){t.call(this,u(this.$root.$options.shadowRoot))}:function(e){t.call(this,l(e))}),d)if(c.functional){var p=c.render;c.render=function(e,t){return d.call(t),p(e,t)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,d):[d]}return r}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;for(var a=require("moment"),n=[],o=0;o<30;o++){var i=a().add(o,"days").format("YYYY-MM-DD");n.push(i)}n.sort(function(e,t){return e.localeCompare(t)}),console.log(n);for(var l=[],s=[],u=0;u<30;u++){var c=Math.floor(81*Math.random())+20;c>30&&c<90?s.push("up"):c>=90?(s.push("NA"),c=null):(s.push("down"),c=null),l.push(c)}var d={date:n,uptime:l,status:s},p=r({render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plot"}})},staticRenderFns:[]},void 0,{name:"accessibilityPlot",mounted:function(){var e=this.buildTimeTraces(d);e=e.concat(this.buildBarTraces(d));var r=d.uptime.filter(function(e){return null!==e}),a=r.reduce(function(e,t){return e+t},0)/r.length,n=new Date(d.date[0]);n.setDate(n.getDate()-1);var o=new Date(d.date[d.date.length-1]);o.setDate(o.getDate()+1),console.log(a);var i={x:[n,o],y:[a,a],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba(111, 176, 129,.6)",width:1.5,dash:"4px"},marker:{size:5}};e.push(i);var l={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:400,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:Math.min(d.x),dtick:2592e5,tickangle:45,tickformat:"%d %b",ticklabelmode:"period"},yaxis:{title:"Access time (ms)",titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}}};t.newPlot("plot",e,l)},methods:{generateColor:function(e,t){for(var r=[],a=0;a<30;a++)switch(e[a]){case"up":r.push("rgba(218, 247, 223,0)");break;case"down":r.push("rgba(255, 153, 145,"+t+")");break;case"NA":r.push("rgba(204,204,204,"+t+")")}return console.log(r),r},extractSubarraysBetweenNullValues:function(e){for(var t=[],r=[],a=[],n=[],o=0;o<e.uptime.length;o++)null===e.uptime[o]?a.length>0&&(t.push(a),r.push(n),a=[],n=[]):(a.push(e.uptime[o]),n.push(e.date[o]));return a.length>0&&(t.push(a),r.push(n)),{uptime:t,date:r}},buildTimeTraces:function(e){for(var t=this.extractSubarraysBetweenNullValues(e),r=[],a=0;a<t.uptime.length;a++){var n=t.uptime[a],o={x:t.date[a],y:n,name:"Online",legendgroup:"up",showlegend:0===a,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba(218, 247, 223,.4)",connectgaps:!1,line:{color:"rgba(111, 176, 129,.8)",width:1.5},marker:{size:5}};r.push(o)}return r},extractSubarraysOfNullValues:function(e,t){for(var r=[],a=0;a<e.uptime.length;a++)null===e.uptime[a]&&e.status[a]===t&&r.push(e.date[a]);return r},buildBarTraces:function(e){var t=[],r=this.extractSubarraysOfNullValues(e,"down");console.log(r);var a=Array(r.length).fill(2).concat(Array(r.length).fill(120)),n=Array(r.length).fill("rgba(255, 153, 145,.8)").concat(Array(r.length).fill("rgba(255, 153, 145,.2)"));r=r.concat(r);var o=this.extractSubarraysOfNullValues(e,"NA"),i=Array(o.length).fill(2).concat(Array(o.length).fill(120)),l=Array(o.length).fill("rgba(204,204,204,.8)").concat(Array(o.length).fill("rgba(204,204,204,.2)"));o=o.concat(o);var s={x:r,y:a,marker:{color:n},name:"Offline",type:"bar"};t.push(s);var u={x:o,y:i,marker:{color:l},name:"No information captured",type:"bar"};return t.push(u),t}}},void 0,!1,void 0,void 0,void 0);e.accessibilityPlot=p,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("plotly.js-dist")):"function"==typeof define&&define.amd?define(["exports","plotly.js-dist"],t):(e=e||self,t(e.oeb_visualizations={},e.Plotly))}(this,function(e,t){"use strict";function i(e,t,i,a,r,s,n,o,l,c){"boolean"!=typeof n&&(l=o,o=n,n=!1);var d="function"==typeof i?i.options:i;e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,r&&(d.functional=!0)),a&&(d._scopeId=a);var u;if(s?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=u):t&&(u=n?function(){t.call(this,c(this.$root.$options.shadowRoot))}:function(e){t.call(this,o(e))}),u)if(d.functional){var p=d.render;d.render=function(e,t){return u.call(t),p(e,t)}}else{var h=d.beforeCreate;d.beforeCreate=h?[].concat(h,u):[u]}return i}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var a=i({render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",{attrs:{id:"plotAccessibility"}})},staticRenderFns:[]},void 0,{name:"accessibilityPlot",props:{dtick:{type:Number,required:!1,default:864e5},xaxisTitle:{type:String,required:!1,default:"Date"},yaxisTitle:{type:String,required:!1,default:"Access time (ms)"},colorOnline:{type:String,required:!1,default:"111, 176, 129"},colorOffline:{type:String,required:!1,default:"255, 153, 145"},colorNA:{type:String,required:!1,default:"204,204,204"},height:{type:Number,required:!1,default:400},dataItems:{type:Array,required:!0,validator:function(e){for(var t=0;t<e.length;t++)e[t].hasOwnProperty("access_time")?e[t].hasOwnProperty("date")?e[t].hasOwnProperty("code")||console.error("[oeb-visualizations warn] code key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] date key is missing in dataItems prop item (at position "+t+")"):console.error("[oeb-visualizations warn] access_time key is missing in dataItems prop item (at position "+t+")"),null!==e[t].access_time&&"number"!=typeof e[t].access_time&&console.error("[oeb-visualizations warn] access_time must be null or a number in dataItems prop item (at position "+t+")"),null!==e[t].code&&"number"!=typeof e[t].code&&console.error("[oeb-visualizations warn] code must be null or a number in dataItems prop item (at position "+t+")"),("string"!=typeof e[t].date||isNaN(Date.parse(e[t].date)))&&console.error("[oeb-visualizations warn] date must be a string containing a date in dataItems prop item (at position "+t+")"),null===e[t].date&&console.error("[oeb-visualizations warn] date cannot be null in dataItems prop item (at position "+t+")");return!0}}},mounted:function(){var e=this.buildOnlineTraces(this.dataItems);e=e.concat(this.buildOfflineNATraces(this.dataItems));var i={bargap:0,barmode:"stack",showlegend:!0,autosize:!0,height:this.height,margin:{l:50,r:50,b:70,t:70,pad:4},xaxis:{type:"date",title:this.xaxisTitle,font:{size:8},tickfont:{size:8},tickmode:"linear",tick0:this.dataItems[0].date,dtick:this.dtick,tickangle:45,tickformat:"%d %b"},yaxis:{title:this.yaxisTitle,titlefont:{size:10},tickfont:{size:8}},template:"plotly_white",legend:{orientation:"h",yanchor:"bottom",y:1.02,xanchor:"right",x:1,font:{size:8}},hoverlabel:{bgcolor:"#FFF"},hovermode:"closest",hoverdistance:70};t.newPlot("plotAccessibility",e,i)},methods:{generateColor:function(e,t){for(var i=[],a=0;a<30;a++)switch(e[a]){case"up":i.push("rgba("+this.colorOnline+",0)");break;case"down":i.push("rgba("+this.colorOffline+","+t+")");break;case"NA":i.push("rgba("+this.colorNA+","+t+")")}return i},extractSubarraysBetweenNullValues:function(e){for(var t={access_time:[],date:[],average_access_time:0},i=[],a=[],r=0,s=0,n=0;n<e.length;n++)null!==e[n].access_time?(i.push(e[n].access_time),a.push(e[n].date),r+=e[n].access_time,s+=1):i.length>0&&(t.access_time.push(i),t.date.push(a),i=[],a=[]);return t.access_time.push(i),t.date.push(a),t.average_access_time=r/s,t},buildAccessTimeTraces:function(e){for(var t=[],i=0;i<e.access_time.length;i++){var a=e.access_time[i],r={x:e.date[i],y:a,name:"Online",legendgroup:"up",showlegend:0===i,mode:"markers+lines",type:"scatter",fill:"tozeroy",fillcolor:"rgba("+this.colorOnline+",.2)",connectgaps:!1,line:{color:"rgba("+this.colorOnline+",.8)",width:1.5},marker:{size:5},hovertemplate:"<b>Online</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>",hoveron:"points+fills"};t.push(r)}return t},buildAvgAccessTimeTrace:function(e){var t=new Date(this.dataItems[0].date);t.setDate(t.getDate()-1);var i=new Date(this.dataItems[this.dataItems.length-1].date);return i.setDate(i.getDate()+1),{x:[t,i],y:[e,e],name:"Average access time",showlegend:!0,mode:"lines",type:"scatter",line:{color:"rgba("+this.colorOnline+",.6)",width:1.5,dash:"4px"},marker:{size:5}}},buildOnlineTraces:function(e){var t=this.extractSubarraysBetweenNullValues(e),i=this.buildAccessTimeTraces(t);return i.push(this.buildAvgAccessTimeTrace(t.average_access_time)),i},extractOfflineNADates:function(e){for(var t=[404,500,502,503,504],i=[],a=[],r=0;r<e.length;r++)null===e[r].access_time&&null===e[r].code?i.push(e[r].date):null===e[r].access_time&&t.includes(e[r].code)&&a.push(e[r].date);return{NA:i,down:a}},barTrace:function(e,t,i,a,r){return{x:e.dates,y:e.access_times,marker:{color:e.colors},name:t,type:"bar",legendgroup:"down",showlegend:i,hoverinfo:a,hovertemplate:r}},buildBarTraces:function(e,t,i){var a="rgba("+t+",.8)",r="rgba("+t+",.2)",s={dates:e,access_times:Array(e.length).fill(2),colors:Array(e.length).fill(a)},n={dates:e,access_times:Array(e.length).fill(120),colors:Array(e.length).fill(r)},o="<b>"+i+"</b><br>%{x|%d %b %Y}<br>%{y} ms <extra></extra>";return[this.barTrace(s,i,!1,"skip",""),this.barTrace(n,i,!0,"all",o)]},buildOfflineNATraces:function(e){var t=[],i=this.extractOfflineNADates(e);return t=t.concat(this.buildBarTraces(i.down,this.colorOffline,"Offline")),t=t.concat(this.buildBarTraces(i.NA,this.colorNA,"No information available"))}}},void 0,!1,void 0,void 0,void 0);e.accessibilityPlot=a,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inb/oeb_visualizations",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Collection of Vue components for data visualization in OpenEBench.",
5
5
  "author": "evamart",
6
6
  "license": "MIT",