@perses-dev/pie-chart-plugin 0.10.0 → 0.12.0
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/__mf/css/async/263.d3010b86.css +1 -0
- package/__mf/css/async/341.d3010b86.css +1 -0
- package/__mf/css/async/759.d3010b86.css +1 -0
- package/__mf/js/{PieChart.df86cbf0.js → PieChart.1d58bffe.js} +3 -3
- package/__mf/js/async/156.1cf9ec35.js +1 -0
- package/__mf/js/async/264.6e9f3f27.js +110 -0
- package/__mf/js/async/298.e575048a.js +1 -0
- package/__mf/js/async/398.9b0b9c83.js +1 -0
- package/__mf/js/async/567.672f2dce.js +2 -0
- package/__mf/js/async/706.3e6ace36.js +38 -0
- package/__mf/js/async/711.2e914849.js +22 -0
- package/__mf/js/async/{75.a825d10b.js → 75.b6a33f75.js} +1 -1
- package/__mf/js/async/922.560b8115.js +7 -0
- package/__mf/js/async/__federation_expose_PieChart.6ae68990.js +1 -0
- package/__mf/js/{main.47849ff0.js → main.efe2355f.js} +3 -3
- package/lib/PieChartBase.d.ts +1 -2
- package/lib/PieChartBase.d.ts.map +1 -1
- package/lib/PieChartBase.js +26 -25
- package/lib/PieChartBase.js.map +1 -1
- package/lib/PieChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/PieChartOptionsEditorSettings.js +144 -17
- package/lib/PieChartOptionsEditorSettings.js.map +1 -1
- package/lib/PieChartPanel.d.ts.map +1 -1
- package/lib/PieChartPanel.js +36 -27
- package/lib/PieChartPanel.js.map +1 -1
- package/lib/cjs/PieChartBase.js +24 -23
- package/lib/cjs/PieChartOptionsEditorSettings.js +142 -15
- package/lib/cjs/PieChartPanel.js +35 -26
- package/lib/cjs/colors.js +207 -0
- package/lib/cjs/index.js +2 -4
- package/lib/cjs/pie-chart-model.js +3 -2
- package/lib/cjs/utils.js +10 -30
- package/lib/colors.d.ts +38 -0
- package/lib/colors.d.ts.map +1 -0
- package/lib/colors.js +192 -0
- package/lib/colors.js.map +1 -0
- package/lib/index.d.ts +2 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/pie-chart-model.d.ts +5 -3
- package/lib/pie-chart-model.d.ts.map +1 -1
- package/lib/pie-chart-model.js +3 -2
- package/lib/pie-chart-model.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +10 -30
- package/lib/utils.js.map +1 -1
- package/mf-manifest.json +21 -41
- package/mf-stats.json +21 -44
- package/package.json +4 -4
- package/__mf/css/async/263.80005a4a.css +0 -1
- package/__mf/css/async/341.80005a4a.css +0 -1
- package/__mf/css/async/759.80005a4a.css +0 -1
- package/__mf/js/async/109.77dcc7d9.js +0 -73
- package/__mf/js/async/224.43460380.js +0 -1
- package/__mf/js/async/238.3e689a99.js +0 -1
- package/__mf/js/async/288.4cad0403.js +0 -7
- package/__mf/js/async/289.c295f73f.js +0 -38
- package/__mf/js/async/298.707087d2.js +0 -1
- package/__mf/js/async/470.1e913aa7.js +0 -2
- package/__mf/js/async/680.f1da299d.js +0 -110
- package/__mf/js/async/708.77a1c1f6.js +0 -1
- package/__mf/js/async/740.254a5697.js +0 -1
- package/__mf/js/async/__federation_expose_PieChart.3d887a98.js +0 -1
- package/lib/cjs/model.js +0 -16
- package/lib/cjs/palette-gen.js +0 -63
- package/lib/cjs/palette.js +0 -83
- package/lib/model.d.ts +0 -20
- package/lib/model.d.ts.map +0 -1
- package/lib/model.js +0 -15
- package/lib/model.js.map +0 -1
- package/lib/palette-gen.d.ts +0 -20
- package/lib/palette-gen.d.ts.map +0 -1
- package/lib/palette-gen.js +0 -50
- package/lib/palette-gen.js.map +0 -1
- package/lib/palette.d.ts +0 -6
- package/lib/palette.d.ts.map +0 -1
- package/lib/palette.js +0 -64
- package/lib/palette.js.map +0 -1
- /package/__mf/js/async/{680.f1da299d.js.LICENSE.txt → 264.6e9f3f27.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.1e913aa7.js.LICENSE.txt → 567.672f2dce.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{109.77dcc7d9.js.LICENSE.txt → 711.2e914849.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{288.4cad0403.js.LICENSE.txt → 922.560b8115.js.LICENSE.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.chunk_PieChart=self.chunk_PieChart||[]).push([["740"],{48872:function(e,t,n){n.r(t),n.d(t,{toDate:()=>P,toZonedTime:()=>J,fromZonedTime:()=>L,format:()=>B,formatInTimeZone:()=>K,getTimezoneOffset:()=>Q});var r=n(16332),i=n(57871);function a(e,t,n){var r,a,u;let l=(0,i.getDefaultOptions)(),o=(r=e,a=n.timeZone,u=n.locale??l.locale,new Intl.DateTimeFormat(u?[u.code,"en-US"]:void 0,{timeZone:a,timeZoneName:r}));return"formatToParts"in o?function(e,t){let n=e.formatToParts(t);for(let e=n.length-1;e>=0;--e)if("timeZoneName"===n[e].type)return n[e].value}(o,t):function(e,t){let n=e.format(t).replace(/\u200E/g,""),r=/ [\w-+ ]+$/.exec(n);return r?r[0].substr(1):""}(o,t)}let u={year:0,month:1,day:2,hour:3,minute:4,second:5},l={},o=new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:"America/New_York",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),c="06/25/2014, 00:00:00"===o||"06/25/2014 00:00:00"===o;function s(e,t,n,r,i,a,u){let l=new Date(0);return l.setUTCFullYear(e,t,n),l.setUTCHours(r,i,a,u),l}let f=/^(Z)$/,d=/^([+-]\d{2})$/,g=/^([+-])(\d{2}):?(\d{2})$/;function m(e,t,n){let r,i;if(!e)return 0;let a=f.exec(e);if(a)return 0;if(a=d.exec(e))return h(r=parseInt(a[1],10))?-(36e5*r):NaN;if(a=g.exec(e)){r=parseInt(a[2],10);let e=parseInt(a[3],10);return h(r,e)?(i=36e5*Math.abs(r)+6e4*e,"+"===a[1]?-i:i):NaN}if(function(e){if(N[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),N[e]=!0,!0}catch(e){return!1}}(e)){var u;t=new Date(t||Date.now());let r=D(n?t:s((u=t).getFullYear(),u.getMonth(),u.getDate(),u.getHours(),u.getMinutes(),u.getSeconds(),u.getMilliseconds()),e);return-(n?r:function(e,t,n){let r=e.getTime()-t,i=D(new Date(r),n);if(t===i)return t;let a=D(new Date(r-=i-t),n);return i===a?i:Math.max(i,a)}(t,r,e))}return NaN}function D(e,t){let n=function(e,t){var n;let r=(l[n=t]||(l[n]=c?new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:n,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})),l[n]);return"formatToParts"in r?function(e,t){try{let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let t=u[n[e].type];void 0!==t&&(r[t]=parseInt(n[e].value,10))}return r}catch(e){if(e instanceof RangeError)return[NaN];throw e}}(r,e):function(e,t){let n=e.format(t),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);return[parseInt(r[3],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[4],10),parseInt(r[5],10),parseInt(r[6],10)]}(r,e)}(e,t),r=s(n[0],n[1]-1,n[2],n[3]%24,n[4],n[5],0).getTime(),i=e.getTime(),a=i%1e3;return r-(i-=a>=0?a:1e3+a)}function h(e,t){return -23<=e&&e<=23&&(null==t||0<=t&&t<=59)}let N={},p={X:function(e,t,n){let r=w(n.timeZone,e);if(0===r)return"Z";switch(t){case"X":return I(r);case"XXXX":case"XX":return x(r);default:return x(r,":")}},x:function(e,t,n){let r=w(n.timeZone,e);switch(t){case"x":return I(r);case"xxxx":case"xx":return x(r);default:return x(r,":")}},O:function(e,t,n){let r=w(n.timeZone,e);switch(t){case"O":case"OO":case"OOO":return"GMT"+function(e,t=""){let n=e>0?"-":"+",r=Math.abs(e),i=Math.floor(r/60),a=r%60;return 0===a?n+String(i):n+String(i)+t+T(a,2)}(r,":");default:return"GMT"+x(r,":")}},z:function(e,t,n){switch(t){case"z":case"zz":case"zzz":return a("short",e,n);default:return a("long",e,n)}}};function w(e,t){let n=e?m(e,t,!0)/6e4:t?.getTimezoneOffset()??0;if(Number.isNaN(n))throw RangeError("Invalid time zone specified: "+e);return n}function T(e,t){let n=Math.abs(e).toString();for(;n.length<t;)n="0"+n;return(e<0?"-":"")+n}function x(e,t=""){let n=Math.abs(e);return(e>0?"-":"+")+T(Math.floor(n/60),2)+t+T(Math.floor(n%60),2)}function I(e,t){return e%60==0?(e>0?"-":"+")+T(Math.abs(e)/60,2):x(e,t)}function Z(e){let t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e-t}let y=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,U=/^([0-9W+-]+)(T| )(.*)/,C=/^([0-9W+-]+)(.*)/,M=/^(\d{2})$/,b=[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],F=/^(\d{4})/,S=[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],$=/^-(\d{2})$/,O=/^-?(\d{3})$/,z=/^-?(\d{2})-?(\d{2})$/,Y=/^-?W(\d{2})$/,v=/^-?W(\d{2})-?(\d{1})$/,X=/^(\d{2}([.,]\d*)?)$/,j=/^(\d{2}):?(\d{2}([.,]\d*)?)$/,H=/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/;function P(e,t={}){if(arguments.length<1)throw TypeError("1 argument required, but only "+arguments.length+" present");if(null===e)return new Date(NaN);let n=null==t.additionalDigits?2:Number(t.additionalDigits);if(2!==n&&1!==n&&0!==n)throw RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))return new Date(e.getTime());if("number"==typeof e||"[object Number]"===Object.prototype.toString.call(e))return new Date(e);if("[object String]"!==Object.prototype.toString.call(e))return new Date(NaN);let r=function(e){let t,n={},r=U.exec(e);if(r?(n.date=r[1],t=r[3]):(r=C.exec(e))?(n.date=r[1],t=r[2]):(n.date=null,t=e),t){let e=y.exec(t);e?(n.time=t.replace(e[1],""),n.timeZone=e[1].trim()):n.time=t}return n}(e),{year:i,restDateString:a}=function(e,t){if(e){let n=b[t],r=S[t],i=F.exec(e)||r.exec(e);if(i){let t=i[1];return{year:parseInt(t,10),restDateString:e.slice(t.length)}}if(i=M.exec(e)||n.exec(e)){let t=i[1];return{year:100*parseInt(t,10),restDateString:e.slice(t.length)}}}return{year:null}}(r.date,n),u=function(e,t){let n,r,i;if(null===t)return null;if(!e||!e.length)return(n=new Date(0)).setUTCFullYear(t),n;let a=$.exec(e);if(a)return(n=new Date(0),k(t,r=parseInt(a[1],10)-1))?(n.setUTCFullYear(t,r),n):new Date(NaN);if(a=O.exec(e)){n=new Date(0);let e=parseInt(a[1],10);return!function(e,t){if(t<1)return!1;let n=A(e);return(!n||!(t>366))&&(!!n||!(t>365))}(t,e)?new Date(NaN):(n.setUTCFullYear(t,0,e),n)}if(a=z.exec(e)){n=new Date(0),r=parseInt(a[1],10)-1;let e=parseInt(a[2],10);return k(t,r,e)?(n.setUTCFullYear(t,r,e),n):new Date(NaN)}if(a=Y.exec(e))return R(i=parseInt(a[1],10)-1)?E(t,i):new Date(NaN);if(a=v.exec(e)){i=parseInt(a[1],10)-1;let e=parseInt(a[2],10)-1;return R(i,e)?E(t,i,e):new Date(NaN)}return null}(a,i);if(null===u||isNaN(u.getTime())||!u)return new Date(NaN);{let e,n=u.getTime(),i=0;if(r.time&&(null===(i=function(e){let t,n,r=X.exec(e);if(r)return G(t=parseFloat(r[1].replace(",",".")))?t%24*36e5:NaN;if(r=j.exec(e))return G(t=parseInt(r[1],10),n=parseFloat(r[2].replace(",",".")))?t%24*36e5+6e4*n:NaN;if(r=H.exec(e)){t=parseInt(r[1],10),n=parseInt(r[2],10);let e=parseFloat(r[3].replace(",","."));return G(t,n,e)?t%24*36e5+6e4*n+1e3*e:NaN}return null}(r.time))||isNaN(i)))return new Date(NaN);if(r.timeZone||t.timeZone){if(isNaN(e=m(r.timeZone||t.timeZone,new Date(n+i))))return new Date(NaN)}else e=Z(new Date(n+i)),e=Z(new Date(n+i+e));return new Date(n+i+e)}}function E(e,t,n){t=t||0,n=n||0;let r=new Date(0);r.setUTCFullYear(e,0,4);let i=7*t+n+1-(r.getUTCDay()||7);return r.setUTCDate(r.getUTCDate()+i),r}let W=[31,28,31,30,31,30,31,31,30,31,30,31],_=[31,29,31,30,31,30,31,31,30,31,30,31];function A(e){return e%400==0||e%4==0&&e%100!=0}function k(e,t,n){if(t<0||t>11)return!1;if(null!=n){if(n<1)return!1;let r=A(e);if(r&&n>_[t]||!r&&n>W[t])return!1}return!0}function R(e,t){return!(e<0)&&!(e>52)&&(null==t||!(t<0)&&!(t>6))}function G(e,t,n){return!(e<0)&&!(e>=25)&&(null==t||!(t<0)&&!(t>=60))&&(null==n||!(n<0)&&!(n>=60))}let q=/([xXOz]+)|''|'(''|[^'])+('|$)/g;function B(e,t,n={}){let i=(t=String(t)).match(q);if(i){let r=P(n.originalDate||e,n);t=i.reduce(function(e,t){if("'"===t[0])return e;let i=e.indexOf(t),a="'"===e[i-1],u=e.replace(t,"'"+p[t[0]](r,t,n)+"'");return a?u.substring(0,i-1)+u.substring(i+1):u},t)}return(0,r.WU)(e,t,n)}function J(e,t,n){let r=m(t,e=P(e,n),!0),i=new Date(e.getTime()-r),a=new Date(0);return a.setFullYear(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()),a.setHours(i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),i.getUTCMilliseconds()),a}function K(e,t,n,r){return r={...r,timeZone:t,originalDate:e},B(J(e,t,{timeZone:r.timeZone}),n,r)}function L(e,t,n){if("string"==typeof e&&!e.match(y))return P(e,{...n,timeZone:t});let r=s((e=P(e,n)).getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()).getTime(),i=m(t,new Date(r));return new Date(r+i)}function Q(e,t){return-m(e,t)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.chunk_PieChart=self.chunk_PieChart||[]).push([["703"],{36942:function(e,t,l){l.r(t),l.d(t,{PieChart:()=>T});var a=l(14046);let n={unit:"decimal",shortValues:!0},r="desc";var i=l(24246),o=l(15409),s=l.n(o),d=l(87570),u=l(75586),h=l(64010),c=l(1148),m=l(48565),g=l(94776),p=l(36372),v=l(8193),f=l(54538),x=l(83915);let C=new x.Z({hue:{min:20,max:360}}),y=new x.Z({hue:{min:0,max:20}}),b={};function S(e){let t=e.reduce((e,t)=>{let{value:l}=t;return e+(l??0)},0);return e.map(e=>{let l=(e.value??0)/t*100;return{...e,value:l}})}var w=l(36232),j=l(85731),$=l(65201),E=l(99635),O=l(23709),P=l(67745),L=l(50378);function N(e){let{width:t,height:l,data:a}=e,n=(0,h.useChartsTheme)(),r={title:{text:"Referer of a Website",subtext:"Fake Data",left:"center"},tooltip:{trigger:"item",formatter:"{b} : {c} ({d}%)"},axisLabel:{overflow:"truncate",width:t/3},series:[{type:"pie",radius:"55%",label:!1,center:["40%","50%"],data:a,emphasis:{itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}}}],itemStyle:{borderRadius:2,color:n.echartsTheme[0]}};return(0,i.jsx)(p.Z,{style:{width:t,height:l},sx:{overflow:"auto"},children:(0,i.jsx)(h.EChart,{sx:{minHeight:l,height:a?16*a.length:"100%"},option:r,theme:n.echartsTheme})})}(0,w.D)([j.N,$.N,E.N,O.N,P.N,L.N]);let T={PanelComponent:function(e){let{spec:{calculation:t,sort:l,mode:n,legend:o},contentDimensions:u,queryResults:c}=e,m=(0,h.useChartsTheme)(),x=(0,g.Z)(),w=m.container.padding.default,j=(0,h.useId)("time-series-panel"),$=m.echartsTheme.color,{pieChartData:E,legendItems:O,legendColumns:P}=(0,f.useMemo)(()=>{var e;let i=a.c7[t],s=[],u=[],h=[];for(let e=0;e<c.length;e++){let t=c[e],l=0;for(let e of(null==t?void 0:t.data.series)??[]){let t=function(e){var t,l;let{categoricalPalette:a,muiPrimaryColor:n,seriesName:r}=e;return t=r,l=Array.isArray(a)&&a[0]?a[0]:n,function(e){var t=e.toLowerCase().includes("error");let l=`${e}_____${t}`,a=b[l];return a||(a=function(e,t){let[l,a,n]=t?y.hsl(e):C.hsl(e),r=`${(100*a).toFixed(0)}%`,i=`${(100*n).toFixed(0)}%`;return`hsla(${l.toFixed(2)},${r},${i},0.9)`}(e,t),b[l]=a),a}(t)??l}({categoricalPalette:$,muiPrimaryColor:x.palette.primary.main,seriesName:e.name}),a=`${j}${e.name}${l}`,n={id:a,value:i(e.values)??null,name:e.formattedName??"",itemStyle:{color:t}};s.push(n),u.push({id:a,label:n.name,color:t,data:{}}),l++}}let m=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;return"asc"===t?e.sort((e,t)=>null===e.value?1:null===t.value?-1:e.value===t.value?0:e.value<t.value?1:-1):e.sort((e,t)=>null===e.value?-1:null===t.value?1:e.value===t.value?0:e.value<t.value?-1:1)}(s,l);if((null==o||null==(e=o.values)?void 0:e.length)&&(null==o?void 0:o.mode)==="table"){let{values:e}=o;[...e].sort().forEach(e=>{var t,l;switch(h.push({accessorKey:`data.${e}`,header:(null==(t=d.comparisonLegends[e])?void 0:t.label)||e,headerDescription:null==(l=d.comparisonLegends[e])?void 0:l.description,width:90,align:"right",cellDescription:!0,enableSorting:!0}),e){case"abs":u.forEach(e=>{let{value:t}=s.find(t=>e.id===t.id)||{};"number"==typeof t&&e.data&&(e.data.abs=t)});break;case"relative":u.forEach(e=>{let{value:t}=S(m).find(t=>e.id===t.id)||{};"number"==typeof t&&e.data&&(e.data.relative=`${t.toFixed(2)}%`)})}})}return{pieChartData:"percentage"===n?S(m):m,legendItems:u,legendColumns:h}},[t,l,n,c,$,x.palette.primary.main,j,o]),L=m.container.padding.default,T=u?{width:u.width-2*L,height:u.height-2*L}:void 0,M=(0,f.useMemo)(()=>e.spec.legend&&(0,d.validateLegendSpec)(e.spec.legend)?s()({},v.zx,e.spec.legend):void 0,[e.spec.legend]),[Z,_]=(0,f.useState)("ALL"),[D,F]=(0,f.useState)(),I=(0,f.useRef)(null);return u?(0,i.jsx)(p.Z,{sx:{padding:`${w}px`},children:(0,i.jsx)(h.ContentWithLegend,{width:(null==T?void 0:T.width)??400,height:(null==T?void 0:T.height)??1e3,minChildrenHeight:50,legendSize:null==M?void 0:M.size,legendProps:M&&{options:M,data:O,selectedItems:Z,onSelectedItemsChange:_,tableProps:{columns:P,sorting:D,onSortingChange:F},onItemMouseOver:(e,t)=>{var l;let{id:a}=t;null==(l=I.current)||l.highlightSeries({name:a})},onItemMouseOut:()=>{var e;null==(e=I.current)||e.clearHighlightedSeries()}},children:e=>{let{height:t,width:l}=e;return(0,i.jsx)(p.Z,{style:{height:t,width:l},children:(0,i.jsx)(N,{data:E,width:u.width-2*w,height:u.height-2*w})})}})}):null},panelOptionsEditorComponents:[{label:"Settings",content:function(e){let{onChange:t,value:l}=e,a=s()({},n,l.format);return(0,i.jsxs)(h.OptionsEditorGrid,{children:[(0,i.jsxs)(h.OptionsEditorColumn,{children:[(0,i.jsx)(d.LegendOptionsEditor,{calculation:"comparison",value:l.legend,onChange:e=>{t((0,u.Uy)(l,t=>{t.legend=e}))}}),(0,i.jsxs)(h.OptionsEditorGroup,{title:"Misc",children:[(0,i.jsx)(h.FormatControls,{value:a,onChange:e=>{t((0,u.Uy)(l,t=>{t.format=e}))},disabled:"percentage"===l.mode}),(0,i.jsx)(d.CalculationSelector,{value:l.calculation,onChange:e=>{t((0,u.Uy)(l,t=>{t.calculation=e}))}}),(0,i.jsx)(h.SortSelector,{value:l.sort,onChange:e=>{t((0,u.Uy)(l,t=>{t.sort=e}))}}),(0,i.jsx)(h.ModeSelector,{value:l.mode,onChange:e=>{t((0,u.Uy)(l,t=>{t.mode=e}))},disablePercentageMode:(0,c.PX)(a)})]})]}),(0,i.jsx)(h.OptionsEditorColumn,{children:(0,i.jsx)(h.OptionsEditorGroup,{title:"Reset Settings",children:(0,i.jsx)(m.Z,{variant:"outlined",color:"secondary",onClick:()=>{t((0,u.Uy)(l,e=>{e.legend=void 0}))},children:"Reset To Defaults"})})})]})}}],supportedQueryTypes:["TimeSeriesQuery"],createInitialOptions:function(){return{calculation:a.K2,format:n,radius:50,sort:r,mode:"value"}}}}}]);
|
package/lib/cjs/model.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
package/lib/cjs/palette-gen.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
getAutoPaletteColor: function() {
|
|
25
|
-
return getAutoPaletteColor;
|
|
26
|
-
},
|
|
27
|
-
getCategoricalPaletteColor: function() {
|
|
28
|
-
return getCategoricalPaletteColor;
|
|
29
|
-
},
|
|
30
|
-
getConsistentSeriesNameColor: function() {
|
|
31
|
-
return getConsistentSeriesNameColor;
|
|
32
|
-
},
|
|
33
|
-
getSeriesColor: function() {
|
|
34
|
-
return getSeriesColor;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
const _palette = require("./palette");
|
|
38
|
-
function getSeriesColor(props) {
|
|
39
|
-
const { categoricalPalette, muiPrimaryColor, seriesName } = props;
|
|
40
|
-
// Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
|
|
41
|
-
const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
|
|
42
|
-
: muiPrimaryColor;
|
|
43
|
-
return getAutoPaletteColor(seriesName, fallbackColor);
|
|
44
|
-
}
|
|
45
|
-
function getAutoPaletteColor(name, fallbackColor) {
|
|
46
|
-
// corresponds to 'Auto' in palette.kind for generative color palette
|
|
47
|
-
const generatedColor = getConsistentSeriesNameColor(name);
|
|
48
|
-
return generatedColor ?? fallbackColor;
|
|
49
|
-
}
|
|
50
|
-
function getCategoricalPaletteColor(palette, seriesIndex, fallbackColor) {
|
|
51
|
-
if (palette === undefined) {
|
|
52
|
-
return fallbackColor;
|
|
53
|
-
}
|
|
54
|
-
// Loop through predefined static color palette
|
|
55
|
-
const paletteTotalColors = palette.length ?? 1;
|
|
56
|
-
const paletteIndex = seriesIndex % paletteTotalColors;
|
|
57
|
-
// fallback color comes from echarts theme
|
|
58
|
-
const seriesColor = palette[paletteIndex] ?? fallbackColor;
|
|
59
|
-
return seriesColor;
|
|
60
|
-
}
|
|
61
|
-
function getConsistentSeriesNameColor(inputString) {
|
|
62
|
-
return (0, _palette.getConsistentColor)(inputString, inputString.toLowerCase().includes('error'));
|
|
63
|
-
}
|
package/lib/cjs/palette.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
getConsistentCategoricalColor: function() {
|
|
25
|
-
return getConsistentCategoricalColor;
|
|
26
|
-
},
|
|
27
|
-
getConsistentColor: function() {
|
|
28
|
-
return getConsistentColor;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
|
|
32
|
-
function _interop_require_default(obj) {
|
|
33
|
-
return obj && obj.__esModule ? obj : {
|
|
34
|
-
default: obj
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
38
|
-
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
39
|
-
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
40
|
-
// Items with "error" in them will always be generated as red.
|
|
41
|
-
const ERROR_HUE_CUTOFF = 20;
|
|
42
|
-
const colorGenerator = new _colorhash.default({
|
|
43
|
-
hue: {
|
|
44
|
-
min: ERROR_HUE_CUTOFF,
|
|
45
|
-
max: 360
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const redColorGenerator = new _colorhash.default({
|
|
49
|
-
hue: {
|
|
50
|
-
min: 0,
|
|
51
|
-
max: ERROR_HUE_CUTOFF
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
function computeConsistentColor(name, error) {
|
|
55
|
-
const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
|
|
56
|
-
const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
|
|
57
|
-
const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
|
|
58
|
-
return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
|
|
59
|
-
}
|
|
60
|
-
// To check whether a color has already been generated for a given string.
|
|
61
|
-
// TODO: Predefined color aliases will be defined here
|
|
62
|
-
const colorLookup = {};
|
|
63
|
-
function getConsistentColor(name, error) {
|
|
64
|
-
const key = `${name}_____${error}`;
|
|
65
|
-
let value = colorLookup[key];
|
|
66
|
-
if (!value) {
|
|
67
|
-
value = computeConsistentColor(name, error);
|
|
68
|
-
colorLookup[key] = value;
|
|
69
|
-
}
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
|
|
73
|
-
const palette = error ? errorPalette : categoricalPalette;
|
|
74
|
-
if (palette.length === 0) {
|
|
75
|
-
console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
|
|
76
|
-
return '#000';
|
|
77
|
-
}
|
|
78
|
-
let hash = 0;
|
|
79
|
-
for(let i = 0; i < name.length; i++){
|
|
80
|
-
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
81
|
-
}
|
|
82
|
-
return palette[Math.abs(hash) % palette.length] ?? '#000';
|
|
83
|
-
}
|
package/lib/model.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface QuerySettingsOptions {
|
|
2
|
-
queryIndex: number;
|
|
3
|
-
colorMode: 'fixed' | 'fixed-single';
|
|
4
|
-
colorValue: string;
|
|
5
|
-
}
|
|
6
|
-
export interface ChartPaletteOptions {
|
|
7
|
-
mode: 'auto' | 'categorical';
|
|
8
|
-
}
|
|
9
|
-
export type StackOptions = 'none' | 'all';
|
|
10
|
-
export type ChartVisualOptions = {
|
|
11
|
-
display?: 'line' | 'bar';
|
|
12
|
-
lineWidth?: number;
|
|
13
|
-
areaOpacity?: number;
|
|
14
|
-
showPoints?: 'auto' | 'always';
|
|
15
|
-
palette?: ChartPaletteOptions;
|
|
16
|
-
pointRadius?: number;
|
|
17
|
-
stack?: StackOptions;
|
|
18
|
-
connectNulls?: boolean;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=model.d.ts.map
|
package/lib/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,GAAG,cAAc,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC"}
|
package/lib/model.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
export { };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=model.js.map
|
package/lib/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface QuerySettingsOptions {\n queryIndex: number;\n colorMode: 'fixed' | 'fixed-single';\n colorValue: string;\n}\n\nexport interface ChartPaletteOptions {\n mode: 'auto' | 'categorical';\n}\n\nexport type StackOptions = 'none' | 'all';\n\nexport type ChartVisualOptions = {\n display?: 'line' | 'bar';\n lineWidth?: number;\n areaOpacity?: number;\n showPoints?: 'auto' | 'always';\n palette?: ChartPaletteOptions;\n pointRadius?: number;\n stack?: StackOptions;\n connectNulls?: boolean;\n};\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC,WASE"}
|
package/lib/palette-gen.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface SeriesColorProps {
|
|
2
|
-
categoricalPalette: string[];
|
|
3
|
-
muiPrimaryColor: string;
|
|
4
|
-
seriesName: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
|
|
8
|
-
*/
|
|
9
|
-
export declare function getSeriesColor(props: SeriesColorProps): string;
|
|
10
|
-
/**
|
|
11
|
-
* Get color from generative color palette, this approaches uses series name as the seed and
|
|
12
|
-
* allows for consistent colors across panels (when all panels use this approach).
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAutoPaletteColor(name: string, fallbackColor: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Default classical qualitative palette that cycles through the colors array by index.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getCategoricalPaletteColor(palette: string[], seriesIndex: number, fallbackColor: string): string;
|
|
19
|
-
export declare function getConsistentSeriesNameColor(inputString: string): string;
|
|
20
|
-
//# sourceMappingURL=palette-gen.d.ts.map
|
package/lib/palette-gen.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"palette-gen.d.ts","sourceRoot":"","sources":["../../src/palette-gen.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAU9D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAI/E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAUhH;AAKD,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExE"}
|
package/lib/palette-gen.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { getConsistentColor } from './palette';
|
|
14
|
-
/**
|
|
15
|
-
* Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative
|
|
16
|
-
*/ export function getSeriesColor(props) {
|
|
17
|
-
const { categoricalPalette, muiPrimaryColor, seriesName } = props;
|
|
18
|
-
// Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.
|
|
19
|
-
const fallbackColor = Array.isArray(categoricalPalette) && categoricalPalette[0] ? categoricalPalette[0] // Needed since echarts color property isn't always an array.
|
|
20
|
-
: muiPrimaryColor;
|
|
21
|
-
return getAutoPaletteColor(seriesName, fallbackColor);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get color from generative color palette, this approaches uses series name as the seed and
|
|
25
|
-
* allows for consistent colors across panels (when all panels use this approach).
|
|
26
|
-
*/ export function getAutoPaletteColor(name, fallbackColor) {
|
|
27
|
-
// corresponds to 'Auto' in palette.kind for generative color palette
|
|
28
|
-
const generatedColor = getConsistentSeriesNameColor(name);
|
|
29
|
-
return generatedColor ?? fallbackColor;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Default classical qualitative palette that cycles through the colors array by index.
|
|
33
|
-
*/ export function getCategoricalPaletteColor(palette, seriesIndex, fallbackColor) {
|
|
34
|
-
if (palette === undefined) {
|
|
35
|
-
return fallbackColor;
|
|
36
|
-
}
|
|
37
|
-
// Loop through predefined static color palette
|
|
38
|
-
const paletteTotalColors = palette.length ?? 1;
|
|
39
|
-
const paletteIndex = seriesIndex % paletteTotalColors;
|
|
40
|
-
// fallback color comes from echarts theme
|
|
41
|
-
const seriesColor = palette[paletteIndex] ?? fallbackColor;
|
|
42
|
-
return seriesColor;
|
|
43
|
-
}
|
|
44
|
-
/*
|
|
45
|
-
* Generate a consistent series name color (if series name includes 'error', it will have a red hue).
|
|
46
|
-
*/ export function getConsistentSeriesNameColor(inputString) {
|
|
47
|
-
return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=palette-gen.js.map
|
package/lib/palette-gen.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/palette-gen.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getConsistentColor } from './palette';\n\nexport interface SeriesColorProps {\n categoricalPalette: string[];\n muiPrimaryColor: string;\n seriesName: string;\n}\n\n/**\n * Get line color as well as color for tooltip and legend, account for whether palette is 'categorical' or 'auto' aka generative\n */\nexport function getSeriesColor(props: SeriesColorProps): string {\n const { categoricalPalette, muiPrimaryColor, seriesName } = props;\n\n // Fallback is unlikely to set unless echarts theme palette in charts theme provider is undefined.\n const fallbackColor =\n Array.isArray(categoricalPalette) && categoricalPalette[0]\n ? (categoricalPalette[0] as string) // Needed since echarts color property isn't always an array.\n : muiPrimaryColor;\n\n return getAutoPaletteColor(seriesName, fallbackColor);\n}\n\n/**\n * Get color from generative color palette, this approaches uses series name as the seed and\n * allows for consistent colors across panels (when all panels use this approach).\n */\nexport function getAutoPaletteColor(name: string, fallbackColor: string): string {\n // corresponds to 'Auto' in palette.kind for generative color palette\n const generatedColor = getConsistentSeriesNameColor(name);\n return generatedColor ?? fallbackColor;\n}\n\n/**\n * Default classical qualitative palette that cycles through the colors array by index.\n */\nexport function getCategoricalPaletteColor(palette: string[], seriesIndex: number, fallbackColor: string): string {\n if (palette === undefined) {\n return fallbackColor;\n }\n // Loop through predefined static color palette\n const paletteTotalColors = palette.length ?? 1;\n const paletteIndex = seriesIndex % paletteTotalColors;\n // fallback color comes from echarts theme\n const seriesColor = palette[paletteIndex] ?? fallbackColor;\n return seriesColor;\n}\n\n/*\n * Generate a consistent series name color (if series name includes 'error', it will have a red hue).\n */\nexport function getConsistentSeriesNameColor(inputString: string): string {\n return getConsistentColor(inputString, inputString.toLowerCase().includes('error'));\n}\n"],"names":["getConsistentColor","getSeriesColor","props","categoricalPalette","muiPrimaryColor","seriesName","fallbackColor","Array","isArray","getAutoPaletteColor","name","generatedColor","getConsistentSeriesNameColor","getCategoricalPaletteColor","palette","seriesIndex","undefined","paletteTotalColors","length","paletteIndex","seriesColor","inputString","toLowerCase","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,kBAAkB,QAAQ,YAAY;AAQ/C;;CAEC,GACD,OAAO,SAASC,eAAeC,KAAuB;IACpD,MAAM,EAAEC,kBAAkB,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGH;IAE5D,kGAAkG;IAClG,MAAMI,gBACJC,MAAMC,OAAO,CAACL,uBAAuBA,kBAAkB,CAAC,EAAE,GACrDA,kBAAkB,CAAC,EAAE,CAAY,6DAA6D;OAC/FC;IAEN,OAAOK,oBAAoBJ,YAAYC;AACzC;AAEA;;;CAGC,GACD,OAAO,SAASG,oBAAoBC,IAAY,EAAEJ,aAAqB;IACrE,qEAAqE;IACrE,MAAMK,iBAAiBC,6BAA6BF;IACpD,OAAOC,kBAAkBL;AAC3B;AAEA;;CAEC,GACD,OAAO,SAASO,2BAA2BC,OAAiB,EAAEC,WAAmB,EAAET,aAAqB;IACtG,IAAIQ,YAAYE,WAAW;QACzB,OAAOV;IACT;IACA,+CAA+C;IAC/C,MAAMW,qBAAqBH,QAAQI,MAAM,IAAI;IAC7C,MAAMC,eAAeJ,cAAcE;IACnC,0CAA0C;IAC1C,MAAMG,cAAcN,OAAO,CAACK,aAAa,IAAIb;IAC7C,OAAOc;AACT;AAEA;;CAEC,GACD,OAAO,SAASR,6BAA6BS,WAAmB;IAC9D,OAAOrB,mBAAmBqB,aAAaA,YAAYC,WAAW,GAAGC,QAAQ,CAAC;AAC5E"}
|
package/lib/palette.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return a consistent color for (name, error) tuple
|
|
3
|
-
*/
|
|
4
|
-
export declare function getConsistentColor(name: string, error: boolean): string;
|
|
5
|
-
export declare function getConsistentCategoricalColor(name: string, error: boolean, categoricalPalette: string[], errorPalette: string[]): string;
|
|
6
|
-
//# sourceMappingURL=palette.d.ts.map
|
package/lib/palette.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/palette.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAQvE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,kBAAkB,EAAE,MAAM,EAAE,EAC5B,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,CAaR"}
|
package/lib/palette.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import ColorHash from 'color-hash';
|
|
14
|
-
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
15
|
-
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
16
|
-
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
17
|
-
// Items with "error" in them will always be generated as red.
|
|
18
|
-
const ERROR_HUE_CUTOFF = 20;
|
|
19
|
-
const colorGenerator = new ColorHash({
|
|
20
|
-
hue: {
|
|
21
|
-
min: ERROR_HUE_CUTOFF,
|
|
22
|
-
max: 360
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
const redColorGenerator = new ColorHash({
|
|
26
|
-
hue: {
|
|
27
|
-
min: 0,
|
|
28
|
-
max: ERROR_HUE_CUTOFF
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
function computeConsistentColor(name, error) {
|
|
32
|
-
const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
|
|
33
|
-
const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
|
|
34
|
-
const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
|
|
35
|
-
return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
|
|
36
|
-
}
|
|
37
|
-
// To check whether a color has already been generated for a given string.
|
|
38
|
-
// TODO: Predefined color aliases will be defined here
|
|
39
|
-
const colorLookup = {};
|
|
40
|
-
/**
|
|
41
|
-
* Return a consistent color for (name, error) tuple
|
|
42
|
-
*/ export function getConsistentColor(name, error) {
|
|
43
|
-
const key = `${name}_____${error}`;
|
|
44
|
-
let value = colorLookup[key];
|
|
45
|
-
if (!value) {
|
|
46
|
-
value = computeConsistentColor(name, error);
|
|
47
|
-
colorLookup[key] = value;
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
export function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
|
|
52
|
-
const palette = error ? errorPalette : categoricalPalette;
|
|
53
|
-
if (palette.length === 0) {
|
|
54
|
-
console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
|
|
55
|
-
return '#000';
|
|
56
|
-
}
|
|
57
|
-
let hash = 0;
|
|
58
|
-
for(let i = 0; i < name.length; i++){
|
|
59
|
-
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
60
|
-
}
|
|
61
|
-
return palette[Math.abs(hash) % palette.length] ?? '#000';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=palette.js.map
|
package/lib/palette.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/palette.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\nexport function getConsistentCategoricalColor(\n name: string,\n error: boolean,\n categoricalPalette: string[],\n errorPalette: string[]\n): string {\n const palette = error ? errorPalette : categoricalPalette;\n if (palette.length === 0) {\n console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');\n return '#000';\n }\n\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return palette[Math.abs(hash) % palette.length] ?? '#000';\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentCategoricalColor","categoricalPalette","errorPalette","palette","length","console","warn","hash","i","charCodeAt","Math","abs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAEjF,SAASM,uBAAuBC,IAAY,EAAEC,KAAc;IAC1D,MAAM,CAACN,KAAKO,YAAYC,UAAU,GAAGF,QAAQH,kBAAkBM,GAAG,CAACJ,QAAQN,eAAeU,GAAG,CAACJ;IAC9F,MAAMK,oBAAoB,GAAG,AAACH,CAAAA,aAAa,GAAE,EAAGI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAMC,mBAAmB,GAAG,AAACJ,CAAAA,YAAY,GAAE,EAAGG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAEX,IAAIW,OAAO,CAAC,GAAG,CAAC,EAAED,kBAAkB,CAAC,EAAEE,iBAAiB,KAAK,CAAC;AAC/E;AAEA,0EAA0E;AAC1E,sDAAsD;AACtD,MAAMC,cAAsC,CAAC;AAE7C;;CAEC,GACD,OAAO,SAASC,mBAAmBT,IAAY,EAAEC,KAAc;IAC7D,MAAMS,MAAM,GAAGV,KAAK,KAAK,EAAEC,OAAO;IAClC,IAAIU,QAAQH,WAAW,CAACE,IAAI;IAC5B,IAAI,CAACC,OAAO;QACVA,QAAQZ,uBAAuBC,MAAMC;QACrCO,WAAW,CAACE,IAAI,GAAGC;IACrB;IACA,OAAOA;AACT;AAEA,OAAO,SAASC,8BACdZ,IAAY,EACZC,KAAc,EACdY,kBAA4B,EAC5BC,YAAsB;IAEtB,MAAMC,UAAUd,QAAQa,eAAeD;IACvC,IAAIE,QAAQC,MAAM,KAAK,GAAG;QACxBC,QAAQC,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIpB,KAAKgB,MAAM,EAAEI,IAAK;QACpCD,OAAOnB,KAAKqB,UAAU,CAACD,KAAM,CAAA,AAACD,CAAAA,QAAQ,CAAA,IAAKA,IAAG;IAChD;IAEA,OAAOJ,OAAO,CAACO,KAAKC,GAAG,CAACJ,QAAQJ,QAAQC,MAAM,CAAC,IAAI;AACrD"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|