@fluid-topics/ft-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.
package/build/ft-chart.js CHANGED
@@ -134,7 +134,7 @@ let FtChart = class FtChart extends FtLitElement {
134
134
  let label = this.valueLabels ? this.valueLabels[_i] : this.yAxisName;
135
135
  let singularLabel = this.valueLabelsSingular ? this.valueLabelsSingular[_i] : label;
136
136
  const itemStr = numbers[_i] === 1 ? singularLabel : label;
137
- result += `${numbers[_i]} ${itemStr} ${prefix} ${dateStr}${suffix}</br>`;
137
+ result += `${numbers[_i].toLocaleString()} ${itemStr} ${prefix} ${dateStr}${suffix}</br>`;
138
138
  }
139
139
  return result.substring(0, result.length - 5);
140
140
  }
@@ -9,4 +9,4 @@ 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 n=this;return{tooltip:{trigger:"axis",formatter:t=>n.getTooltip(t)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:i=>n.period===t.Period.DAY||n.period===t.Period.WEEK?(void 0)(1e3*i).format("DD MMM YYYY"):(n.period,t.Period.MONTH,(void 0)(1e3*i).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(n){const i=(void 0)(1e3*n[0].data.value[0]),e=n.map((t=>t.data.value[1]));let r,s,u="";switch(this.period){case t.Period.DAY:r=i.format("DD MMM YYYY"),s="on",this.isThisPeriod(i,t.Period.DAY)&&(u=" so far");break;case t.Period.WEEK:r=i.format("DD MMM YYYY"),s="during the week of",this.isThisPeriod(i,t.Period.WEEK)&&(u=" so far");break;case t.Period.MONTH:s="in",r=i.format("MMMM YYYY"),this.isThisPeriod(i,t.Period.MONTH)&&(u=" so far")}let o="";for(let t=0;t<e.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,i=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const h=1===e[t]?i:n;o+=`${e[t]} ${h} ${s} ${r}${u}</br>`}return o.substring(0,o.length-5)}isThisPeriod(n,i,e=(void 0)()){switch(i){case t.Period.DAY:return n.format("YYYY-MM-DD")===e.clone().startOf("day").format("YYYY-MM-DD");case t.Period.WEEK:return n.clone().startOf("isoWeek").format("YYYY-MM-DD")===e.clone().startOf("isoWeek").format("YYYY-MM-DD");case t.Period.MONTH:return n.month()===e.month()&&n.year()===e.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})],t.FtChart.prototype,"xAxisName",void 0),o([i.property({type:String})],t.FtChart.prototype,"yAxisName",void 0),o([e.jsonProperty(void 0)],t.FtChart.prototype,"valueLabels",void 0),o([e.jsonProperty(void 0)],t.FtChart.prototype,"valueLabelsSingular",void 0),o([i.property({type:Boolean})],t.FtChart.prototype,"barChart",void 0),o([i.property({type:String})],t.FtChart.prototype,"period",void 0),o([e.jsonProperty([])],t.FtChart.prototype,"data",void 0),o([i.query(".sessions-chart")],t.FtChart.prototype,"container",void 0),t.FtChart=o([e.customElement("ft-chart")],t.FtChart),Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.wcUtils);
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 n=this;return{tooltip:{trigger:"axis",formatter:t=>n.getTooltip(t)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:i=>n.period===t.Period.DAY||n.period===t.Period.WEEK?(void 0)(1e3*i).format("DD MMM YYYY"):(n.period,t.Period.MONTH,(void 0)(1e3*i).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(n){const i=(void 0)(1e3*n[0].data.value[0]),e=n.map((t=>t.data.value[1]));let r,s,u="";switch(this.period){case t.Period.DAY:r=i.format("DD MMM YYYY"),s="on",this.isThisPeriod(i,t.Period.DAY)&&(u=" so far");break;case t.Period.WEEK:r=i.format("DD MMM YYYY"),s="during the week of",this.isThisPeriod(i,t.Period.WEEK)&&(u=" so far");break;case t.Period.MONTH:s="in",r=i.format("MMMM YYYY"),this.isThisPeriod(i,t.Period.MONTH)&&(u=" so far")}let o="";for(let t=0;t<e.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,i=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const h=1===e[t]?i:n;o+=`${e[t].toLocaleString()} ${h} ${s} ${r}${u}</br>`}return o.substring(0,o.length-5)}isThisPeriod(n,i,e=(void 0)()){switch(i){case t.Period.DAY:return n.format("YYYY-MM-DD")===e.clone().startOf("day").format("YYYY-MM-DD");case t.Period.WEEK:return n.clone().startOf("isoWeek").format("YYYY-MM-DD")===e.clone().startOf("isoWeek").format("YYYY-MM-DD");case t.Period.MONTH:return n.month()===e.month()&&n.year()===e.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})],t.FtChart.prototype,"xAxisName",void 0),o([i.property({type:String})],t.FtChart.prototype,"yAxisName",void 0),o([e.jsonProperty(void 0)],t.FtChart.prototype,"valueLabels",void 0),o([e.jsonProperty(void 0)],t.FtChart.prototype,"valueLabelsSingular",void 0),o([i.property({type:Boolean})],t.FtChart.prototype,"barChart",void 0),o([i.property({type:String})],t.FtChart.prototype,"period",void 0),o([e.jsonProperty([])],t.FtChart.prototype,"data",void 0),o([i.query(".sessions-chart")],t.FtChart.prototype,"container",void 0),t.FtChart=o([e.customElement("ft-chart")],t.FtChart),Object.defineProperty(t,"t",{value:!0})}({},ftGlobals.lit,ftGlobals.litDecorators,ftGlobals.wcUtils);
@@ -69,7 +69,7 @@ i.version="2.29.2",t=Nn,i.fn=wi,i.min=function(){var t=[].slice.call(arguments,0
69
69
  }
70
70
  `}getTemplate(){return W`
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 n=this;return{tooltip:{trigger:"axis",formatter:t=>n.getTooltip(t)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:i=>n.period===t.Period.DAY||n.period===t.Period.WEEK?(void 0)(1e3*i).format("DD MMM YYYY"):(n.period,t.Period.MONTH,(void 0)(1e3*i).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(n){const i=(void 0)(1e3*n[0].data.value[0]),e=n.map((t=>t.data.value[1]));let r,s,o="";switch(this.period){case t.Period.DAY:r=i.format("DD MMM YYYY"),s="on",this.isThisPeriod(i,t.Period.DAY)&&(o=" so far");break;case t.Period.WEEK:r=i.format("DD MMM YYYY"),s="during the week of",this.isThisPeriod(i,t.Period.WEEK)&&(o=" so far");break;case t.Period.MONTH:s="in",r=i.format("MMMM YYYY"),this.isThisPeriod(i,t.Period.MONTH)&&(o=" so far")}let u="";for(let t=0;t<e.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,i=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const a=1===e[t]?i:n;u+=`${e[t]} ${a} ${s} ${r}${o}</br>`}return u.substring(0,u.length-5)}isThisPeriod(n,i,e=(void 0)()){switch(i){case t.Period.DAY:return n.format("YYYY-MM-DD")===e.clone().startOf("day").format("YYYY-MM-DD");case t.Period.WEEK:return n.clone().startOf("isoWeek").format("YYYY-MM-DD")===e.clone().startOf("isoWeek").format("YYYY-MM-DD");case t.Period.MONTH:return n.month()===e.month()&&n.year()===e.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})],t.FtChart.prototype,"xAxisName",void 0),lt([it({type:String})],t.FtChart.prototype,"yAxisName",void 0),lt([rt(void 0)],t.FtChart.prototype,"valueLabels",void 0),lt([rt(void 0)],t.FtChart.prototype,"valueLabelsSingular",void 0),lt([it({type:Boolean})],t.FtChart.prototype,"barChart",void 0),lt([it({type:String})],t.FtChart.prototype,"period",void 0),lt([rt([])],t.FtChart.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 n=this;return{tooltip:{trigger:"axis",formatter:t=>n.getTooltip(t)},grid:{left:"80px",right:"100px",top:"50px",bottom:"20px"},xAxis:{type:"category",name:this.xAxisName.toUpperCase(),axisTick:{alignWithLabel:!0},axisLabel:{formatter:i=>n.period===t.Period.DAY||n.period===t.Period.WEEK?(void 0)(1e3*i).format("DD MMM YYYY"):(n.period,t.Period.MONTH,(void 0)(1e3*i).format("MMMM YYYY"))}},yAxis:{type:"value",name:this.yAxisName.toUpperCase()},series:this.getSeries()}}getTooltip(n){const i=(void 0)(1e3*n[0].data.value[0]),e=n.map((t=>t.data.value[1]));let r,s,o="";switch(this.period){case t.Period.DAY:r=i.format("DD MMM YYYY"),s="on",this.isThisPeriod(i,t.Period.DAY)&&(o=" so far");break;case t.Period.WEEK:r=i.format("DD MMM YYYY"),s="during the week of",this.isThisPeriod(i,t.Period.WEEK)&&(o=" so far");break;case t.Period.MONTH:s="in",r=i.format("MMMM YYYY"),this.isThisPeriod(i,t.Period.MONTH)&&(o=" so far")}let u="";for(let t=0;t<e.length;t++){let n=this.valueLabels?this.valueLabels[t]:this.yAxisName,i=this.valueLabelsSingular?this.valueLabelsSingular[t]:n;const a=1===e[t]?i:n;u+=`${e[t].toLocaleString()} ${a} ${s} ${r}${o}</br>`}return u.substring(0,u.length-5)}isThisPeriod(n,i,e=(void 0)()){switch(i){case t.Period.DAY:return n.format("YYYY-MM-DD")===e.clone().startOf("day").format("YYYY-MM-DD");case t.Period.WEEK:return n.clone().startOf("isoWeek").format("YYYY-MM-DD")===e.clone().startOf("isoWeek").format("YYYY-MM-DD");case t.Period.MONTH:return n.month()===e.month()&&n.year()===e.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})],t.FtChart.prototype,"xAxisName",void 0),lt([it({type:String})],t.FtChart.prototype,"yAxisName",void 0),lt([rt(void 0)],t.FtChart.prototype,"valueLabels",void 0),lt([rt(void 0)],t.FtChart.prototype,"valueLabelsSingular",void 0),lt([it({type:Boolean})],t.FtChart.prototype,"barChart",void 0),lt([it({type:String})],t.FtChart.prototype,"period",void 0),lt([rt([])],t.FtChart.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-chart",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Display charts from data",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,7 +19,7 @@
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
  },
@@ -29,5 +29,5 @@
29
29
  "peerDependencies": {
30
30
  "echarts": "^5.3.0"
31
31
  },
32
- "gitHead": "cd0a3cb28ec86c2c93fcaecf99cdd1c51e83c8c9"
32
+ "gitHead": "59fc7ad4bb79bb7a36b5edc8217d1279abf471f3"
33
33
  }