@fluid-topics/ft-analytics-sessions-chart 0.1.16 → 0.1.17

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.
@@ -9,7 +9,7 @@ i.version="2.29.2",t=bn,i.fn=Di,i.min=function(){var t=[].slice.call(arguments,0
9
9
  }
10
10
  `}getTemplate(){return n.html`
11
11
  <div class="sessions-chart"></div>
12
- `}firstUpdated(t){var n;super.firstUpdated(t),this.myChart=null===(n=window.echarts)||void 0===n?void 0:n.init(this.container,void 0,{renderer:"svg"}),window.addEventListener("resize",(()=>{var t;null===(t=this.myChart)||void 0===t||t.resize()}))}updated(t){super.updated(t);const n=this.getOptions();n&&this.myChart&&this.myChart.setOption(n)}getOptions(){const t=this;return{tooltip:{trigger:"axis",formatter:n=>t.getTooltip(n)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:n=>t.period===u.DAY||t.period===u.WEEK?(void 0)(1e3*n).format("DD MMM YYYY"):(t.period,u.MONTH,(void 0)(1e3*n).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(t){const n=(void 0)(1e3*t[0].data.value[0]),i=t.map((t=>t.data.value[1]));let e,r,s="";switch(this.period){case u.DAY:e=n.format("DD MMM YYYY"),r="on",this.isThisPeriod(n,u.DAY)&&(s=" so far");break;case u.WEEK:e=n.format("DD MMM YYYY"),r="during the week of",this.isThisPeriod(n,u.WEEK)&&(s=" so far");break;case u.MONTH:r="in",e=n.format("MMMM YYYY"),this.isThisPeriod(n,u.MONTH)&&(s=" so far")}let o="";for(let t=0;t<i.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,u=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const h=1===i[t]?u:n;o+=`${i[t]} ${h} ${r} ${e}${s}</br>`}return o.substring(0,o.length-5)}isThisPeriod(t,n,i=(void 0)()){switch(n){case u.DAY:return t.format("YYYY-MM-DD")===i.clone().startOf("day").format("YYYY-MM-DD");case u.WEEK:return t.clone().startOf("isoWeek").format("YYYY-MM-DD")===i.clone().startOf("isoWeek").format("YYYY-MM-DD");case u.MONTH:return t.month()===i.month()&&t.year()===i.year()}return!1}getSeries(){if(0==this.data.length)return[];const t=this.data[0].length-1;if(0==t)return[];let n=[];for(let i=0;i<t;i++)n[i]={type:this.barChart?"bar":"line",data:this.getData(i)};return n}getData(t){return this.data.map((n=>({value:[n[0],n[t+1]]})))}};o([i.property({type:String})],h.prototype,"xAxisName",void 0),o([i.property({type:String})],h.prototype,"yAxisName",void 0),o([e.jsonProperty(void 0)],h.prototype,"valueLabels",void 0),o([e.jsonProperty(void 0)],h.prototype,"valueLabelsSingular",void 0),o([i.property({type:Boolean})],h.prototype,"barChart",void 0),o([i.property({type:String})],h.prototype,"period",void 0),o([e.jsonProperty([])],h.prototype,"data",void 0),o([i.query(".sessions-chart")],h.prototype,"container",void 0),h=o([e.customElement("ft-chart")],h);var a=function(t,n,i,e){for(var r,s=arguments.length,u=s<3?n:null===e?e=Object.getOwnPropertyDescriptor(n,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(u=(s<3?r(u):s>3?r(n,i,u):r(n,i))||u);return s>3&&u&&Object.defineProperty(n,i,u),u};t.FtAnalyticsSessionsChart=class extends e.FtLitElement{constructor(){super(...arguments),this.baseUrl="",this.period=u.MONTH,this.startDate=(void 0)().startOf("month").add(-3,"months").format("YYYY-MM-DD"),this.endDate=(void 0)().startOf("month").format("YYYY-MM-DD"),this.data=[]}getStyles(){return n.css`
12
+ `}firstUpdated(t){var n;super.firstUpdated(t),this.myChart=null===(n=window.echarts)||void 0===n?void 0:n.init(this.container,void 0,{renderer:"svg"}),window.addEventListener("resize",(()=>{var t;null===(t=this.myChart)||void 0===t||t.resize()}))}updated(t){super.updated(t);const n=this.getOptions();n&&this.myChart&&this.myChart.setOption(n)}getOptions(){const t=this;return{tooltip:{trigger:"axis",formatter:n=>t.getTooltip(n)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:n=>t.period===u.DAY||t.period===u.WEEK?(void 0)(1e3*n).format("DD MMM YYYY"):(t.period,u.MONTH,(void 0)(1e3*n).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(t){const n=(void 0)(1e3*t[0].data.value[0]),i=t.map((t=>t.data.value[1]));let e,r,s="";switch(this.period){case u.DAY:e=n.format("DD MMM YYYY"),r="on",this.isThisPeriod(n,u.DAY)&&(s=" so far");break;case u.WEEK:e=n.format("DD MMM YYYY"),r="during the week of",this.isThisPeriod(n,u.WEEK)&&(s=" so far");break;case u.MONTH:r="in",e=n.format("MMMM YYYY"),this.isThisPeriod(n,u.MONTH)&&(s=" so far")}let o="";for(let t=0;t<i.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,u=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const h=1===i[t]?u:n;o+=`${i[t].toLocaleString()} ${h} ${r} ${e}${s}</br>`}return o.substring(0,o.length-5)}isThisPeriod(t,n,i=(void 0)()){switch(n){case u.DAY:return t.format("YYYY-MM-DD")===i.clone().startOf("day").format("YYYY-MM-DD");case u.WEEK:return t.clone().startOf("isoWeek").format("YYYY-MM-DD")===i.clone().startOf("isoWeek").format("YYYY-MM-DD");case u.MONTH:return t.month()===i.month()&&t.year()===i.year()}return!1}getSeries(){if(0==this.data.length)return[];const t=this.data[0].length-1;if(0==t)return[];let n=[];for(let i=0;i<t;i++)n[i]={type:this.barChart?"bar":"line",data:this.getData(i)};return n}getData(t){return this.data.map((n=>({value:[n[0],n[t+1]]})))}};o([i.property({type:String})],h.prototype,"xAxisName",void 0),o([i.property({type:String})],h.prototype,"yAxisName",void 0),o([e.jsonProperty(void 0)],h.prototype,"valueLabels",void 0),o([e.jsonProperty(void 0)],h.prototype,"valueLabelsSingular",void 0),o([i.property({type:Boolean})],h.prototype,"barChart",void 0),o([i.property({type:String})],h.prototype,"period",void 0),o([e.jsonProperty([])],h.prototype,"data",void 0),o([i.query(".sessions-chart")],h.prototype,"container",void 0),h=o([e.customElement("ft-chart")],h);var a=function(t,n,i,e){for(var r,s=arguments.length,u=s<3?n:null===e?e=Object.getOwnPropertyDescriptor(n,i):e,o=t.length-1;o>=0;o--)(r=t[o])&&(u=(s<3?r(u):s>3?r(n,i,u):r(n,i))||u);return s>3&&u&&Object.defineProperty(n,i,u),u};t.FtAnalyticsSessionsChart=class extends e.FtLitElement{constructor(){super(...arguments),this.baseUrl="",this.period=u.MONTH,this.startDate=(void 0)().startOf("month").add(-3,"months").format("YYYY-MM-DD"),this.endDate=(void 0)().startOf("month").format("YYYY-MM-DD"),this.data=[]}getStyles(){return n.css`
13
13
  .session-chart {
14
14
  width: 100%;
15
15
  height: 100%;
@@ -69,7 +69,7 @@ i.version="2.29.2",t=xn,i.fn=wi,i.min=function(){var t=[].slice.call(arguments,0
69
69
  }
70
70
  `}getTemplate(){return A`
71
71
  <div class="sessions-chart"></div>
72
- `}firstUpdated(t){var n;super.firstUpdated(t),this.myChart=null===(n=window.echarts)||void 0===n?void 0:n.init(this.container,void 0,{renderer:"svg"}),window.addEventListener("resize",(()=>{var t;null===(t=this.myChart)||void 0===t||t.resize()}))}updated(t){super.updated(t);const n=this.getOptions();n&&this.myChart&&this.myChart.setOption(n)}getOptions(){const t=this;return{tooltip:{trigger:"axis",formatter:n=>t.getTooltip(n)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:n=>t.period===ct.DAY||t.period===ct.WEEK?(void 0)(1e3*n).format("DD MMM YYYY"):(t.period,ct.MONTH,(void 0)(1e3*n).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(t){const n=(void 0)(1e3*t[0].data.value[0]),i=t.map((t=>t.data.value[1]));let e,r,s="";switch(this.period){case ct.DAY:e=n.format("DD MMM YYYY"),r="on",this.isThisPeriod(n,ct.DAY)&&(s=" so far");break;case ct.WEEK:e=n.format("DD MMM YYYY"),r="during the week of",this.isThisPeriod(n,ct.WEEK)&&(s=" so far");break;case ct.MONTH:r="in",e=n.format("MMMM YYYY"),this.isThisPeriod(n,ct.MONTH)&&(s=" so far")}let o="";for(let t=0;t<i.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,u=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const a=1===i[t]?u:n;o+=`${i[t]} ${a} ${r} ${e}${s}</br>`}return o.substring(0,o.length-5)}isThisPeriod(t,n,i=(void 0)()){switch(n){case ct.DAY:return t.format("YYYY-MM-DD")===i.clone().startOf("day").format("YYYY-MM-DD");case ct.WEEK:return t.clone().startOf("isoWeek").format("YYYY-MM-DD")===i.clone().startOf("isoWeek").format("YYYY-MM-DD");case ct.MONTH:return t.month()===i.month()&&t.year()===i.year()}return!1}getSeries(){if(0==this.data.length)return[];const t=this.data[0].length-1;if(0==t)return[];let n=[];for(let i=0;i<t;i++)n[i]={type:this.barChart?"bar":"line",data:this.getData(i)};return n}getData(t){return this.data.map((n=>({value:[n[0],n[t+1]]})))}};lt([it({type:String})],dt.prototype,"xAxisName",void 0),lt([it({type:String})],dt.prototype,"yAxisName",void 0),lt([st(void 0)],dt.prototype,"valueLabels",void 0),lt([st(void 0)],dt.prototype,"valueLabelsSingular",void 0),lt([it({type:Boolean})],dt.prototype,"barChart",void 0),lt([it({type:String})],dt.prototype,"period",void 0),lt([st([])],dt.prototype,"data",void 0),lt([
72
+ `}firstUpdated(t){var n;super.firstUpdated(t),this.myChart=null===(n=window.echarts)||void 0===n?void 0:n.init(this.container,void 0,{renderer:"svg"}),window.addEventListener("resize",(()=>{var t;null===(t=this.myChart)||void 0===t||t.resize()}))}updated(t){super.updated(t);const n=this.getOptions();n&&this.myChart&&this.myChart.setOption(n)}getOptions(){const t=this;return{tooltip:{trigger:"axis",formatter:n=>t.getTooltip(n)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:n=>t.period===ct.DAY||t.period===ct.WEEK?(void 0)(1e3*n).format("DD MMM YYYY"):(t.period,ct.MONTH,(void 0)(1e3*n).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(t){const n=(void 0)(1e3*t[0].data.value[0]),i=t.map((t=>t.data.value[1]));let e,r,s="";switch(this.period){case ct.DAY:e=n.format("DD MMM YYYY"),r="on",this.isThisPeriod(n,ct.DAY)&&(s=" so far");break;case ct.WEEK:e=n.format("DD MMM YYYY"),r="during the week of",this.isThisPeriod(n,ct.WEEK)&&(s=" so far");break;case ct.MONTH:r="in",e=n.format("MMMM YYYY"),this.isThisPeriod(n,ct.MONTH)&&(s=" so far")}let o="";for(let t=0;t<i.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,u=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const a=1===i[t]?u:n;o+=`${i[t].toLocaleString()} ${a} ${r} ${e}${s}</br>`}return o.substring(0,o.length-5)}isThisPeriod(t,n,i=(void 0)()){switch(n){case ct.DAY:return t.format("YYYY-MM-DD")===i.clone().startOf("day").format("YYYY-MM-DD");case ct.WEEK:return t.clone().startOf("isoWeek").format("YYYY-MM-DD")===i.clone().startOf("isoWeek").format("YYYY-MM-DD");case ct.MONTH:return t.month()===i.month()&&t.year()===i.year()}return!1}getSeries(){if(0==this.data.length)return[];const t=this.data[0].length-1;if(0==t)return[];let n=[];for(let i=0;i<t;i++)n[i]={type:this.barChart?"bar":"line",data:this.getData(i)};return n}getData(t){return this.data.map((n=>({value:[n[0],n[t+1]]})))}};lt([it({type:String})],dt.prototype,"xAxisName",void 0),lt([it({type:String})],dt.prototype,"yAxisName",void 0),lt([st(void 0)],dt.prototype,"valueLabels",void 0),lt([st(void 0)],dt.prototype,"valueLabelsSingular",void 0),lt([it({type:Boolean})],dt.prototype,"barChart",void 0),lt([it({type:String})],dt.prototype,"period",void 0),lt([st([])],dt.prototype,"data",void 0),lt([
73
73
  /**
74
74
  * @license
75
75
  * Copyright 2017 Google LLC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-analytics-sessions-chart",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Display sessions",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,9 +19,9 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "^0.1.16",
22
+ "@fluid-topics/ft-wc-utils": "^0.1.17",
23
23
  "lit": "2.1.3",
24
24
  "moment": "^2.29.2"
25
25
  },
26
- "gitHead": "cd0a3cb28ec86c2c93fcaecf99cdd1c51e83c8c9"
26
+ "gitHead": "59fc7ad4bb79bb7a36b5edc8217d1279abf471f3"
27
27
  }