@eeacms/react-chart-editor
Version:
plotly.js chart editor react component UI
2 lines • 8.49 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:true});exports.shamefullyDeleteRelatedAnalysisTransforms=exports.shamefullyCreateSplitStyleProps=exports.shamefullyClearAxisTypes=exports.shamefullyAdjustSplitStyleTargetContainers=exports.shamefullyAdjustSizeref=exports.shamefullyAdjustMapbox=exports.shamefullyAdjustGeo=exports.shamefullyAdjustAxisRef=exports.shamefullyAdjustAxisDirection=exports.shamefullyAddTableColumns=void 0;var _axis_ids=require("plotly.js/src/plots/cartesian/axis_ids");var _nested_property=_interopRequireDefault(require("plotly.js/src/lib/nested_property"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(function(){var enterModule=typeof reactHotLoaderGlobal!=="undefined"?reactHotLoaderGlobal.enterModule:undefined;enterModule&&enterModule(module)})();var __signature__=typeof reactHotLoaderGlobal!=="undefined"?reactHotLoaderGlobal.default.signature:function(a){return a};const shamefullyClearAxisTypes=(graphDiv,_ref)=>{let{traceIndexes,update}=_ref;if(!Array.isArray(graphDiv._fullData)){return}let hasSrc=false;for(const key in update){if(key.substr(key.length-3)==="src"){hasSrc=true}}if(hasSrc){clearAxisTypes(graphDiv,traceIndexes)}};exports.shamefullyClearAxisTypes=shamefullyClearAxisTypes;const axLetters=["x","y","z"];function clearAxisTypes(gd,traces){for(let i=0;i<traces.length;i++){const trace=gd._fullData[i];for(let j=0;j<3;j++){const type=axLetters[j];const ax=(0,_axis_ids.getFromId)(gd,trace[type+"axis"]||type);if(ax&&ax.type!=="log"){const axAttr=ax._name;const typeAttr=axAttr+".type";(0,_nested_property.default)(gd.layout,typeAttr).set(null)}}}}const shamefullyAdjustAxisRef=(graphDiv,payload)=>{if(payload.axesToBeGarbageCollected){payload.axesToBeGarbageCollected.forEach(a=>{const axis=a.charAt(0);const axisIdNumber=Number(a.slice(1));(0,_nested_property.default)(graphDiv.layout,"".concat(axis,"axis").concat(axisIdNumber||"")).set(null);Object.keys(graphDiv.layout).filter(key=>key.startsWith(axis+"axis")).forEach(key=>{if((0,_nested_property.default)(graphDiv.layout,"".concat(key,".overlaying")).get()===a){(0,_nested_property.default)(graphDiv.layout,"".concat(key,".overlaying")).set(null)}})})}if(payload.subplotToBeGarbageCollected){(0,_nested_property.default)(graphDiv.layout,payload.subplotToBeGarbageCollected).set(null)}};exports.shamefullyAdjustAxisRef=shamefullyAdjustAxisRef;const geoRegex=/^(geo\d*)\./;const shamefullyAdjustGeo=(_ref2,_ref3)=>{let{layout}=_ref2;let{update}=_ref3;Object.keys(update).forEach(k=>{const geoMatch=geoRegex.exec(k);if(geoMatch){const geo=geoMatch[1];if(update[geo+".scope"]){update[geo+".projection"]={};update[geo+".center"]={}}if(update[geo+".projection.type"]&&(update[geo+".projection.type"]==="albers usa"||layout[geo]&&layout[geo].scope==="usa")){update[geo+".scope"]={};update[geo+".center"]={}}}})};exports.shamefullyAdjustGeo=shamefullyAdjustGeo;const shamefullyAdjustMapbox=gd=>{if(gd.layout&&gd.layout.mapbox&&gd.layout.mapbox.style){return}(0,_nested_property.default)(gd.layout,"mapbox.style").set("open-street-map")};exports.shamefullyAdjustMapbox=shamefullyAdjustMapbox;const shamefullyAddTableColumns=(graphDiv,_ref4)=>{let{traceIndexes,update}=_ref4;if(update["cells.values"]&&(!graphDiv.data[traceIndexes[0]].header||!graphDiv.data[traceIndexes[0]].header.valuessrc)){update["header.values"]=update["cells.valuessrc"]}else if(update["header.values"]===null){update["header.values"]=graphDiv.data[traceIndexes[0]].cells.valuessrc||null}else if(update["cells.values"]===null&&!graphDiv.data[traceIndexes[0]].header.valuessrc){update["header.values"]=null}};exports.shamefullyAddTableColumns=shamefullyAddTableColumns;const shamefullyAdjustSplitStyleTargetContainers=(graphDiv,_ref5)=>{let{traceIndexes,update}=_ref5;for(const attr in update){if(attr&&attr.startsWith("transforms")&&attr.endsWith("groups")){const transformIndex=parseInt(attr.split("[")[1],10);const transform=graphDiv.data[traceIndexes[0]].transforms[transformIndex];if(transform&&transform.type==="groupby"&&transform.styles){if(!transform.styles.length&&update[attr]&&Array.isArray(update[attr])){const dedupedGroups=[];update[attr].forEach(group=>{if(!dedupedGroups.includes(group)){dedupedGroups.push(group)}});const styles=dedupedGroups.map(groupEl=>({target:groupEl,value:{}}));update["transforms[".concat(transformIndex,"].styles")]=styles}if(transform.styles.length&&!update[attr]){update["transforms[".concat(transformIndex,"].styles")]=[]}}}}};exports.shamefullyAdjustSplitStyleTargetContainers=shamefullyAdjustSplitStyleTargetContainers;const shamefullyCreateSplitStyleProps=(graphDiv,attr,traceIndex,splitTraceGroup)=>{if(!Array.isArray(splitTraceGroup)){splitTraceGroup=[splitTraceGroup]}let indexOfSplitTransform=null;graphDiv.data[traceIndex].transforms.forEach((t,i)=>{if(t.type==="groupby"){indexOfSplitTransform=i}});function getProp(group){let indexOfStyleObject=null;graphDiv.data[traceIndex].transforms[indexOfSplitTransform].styles.forEach((s,i)=>{if(s.target.toString()===group){indexOfStyleObject=i}});let path=graphDiv.data[traceIndex].transforms[indexOfSplitTransform].styles[indexOfStyleObject].value;attr.split(".").forEach(p=>{if(!path[p]){path[p]={}}path=path[p]});return(0,_nested_property.default)(graphDiv.data[traceIndex].transforms[indexOfSplitTransform].styles[indexOfStyleObject].value,attr)}return splitTraceGroup.map(g=>getProp(g))};exports.shamefullyCreateSplitStyleProps=shamefullyCreateSplitStyleProps;const shamefullyDeleteRelatedAnalysisTransforms=(graphDiv,payload)=>{const parentTraceDataIndex=payload.traceIndexes[0];const parentUid=graphDiv.data[parentTraceDataIndex].uid;if(parentUid){const relatedAnalysisTraceIndexes=[];graphDiv.data.forEach((d,i)=>{if(d.transforms&&d.transforms.some(transform=>["moving-average","fit"].includes(transform.type)&&transform.inputUid===parentUid)){relatedAnalysisTraceIndexes.push(i)}});if(relatedAnalysisTraceIndexes.length){relatedAnalysisTraceIndexes.forEach(i=>{graphDiv.data.splice(i,1)})}}};exports.shamefullyDeleteRelatedAnalysisTransforms=shamefullyDeleteRelatedAnalysisTransforms;const shamefullyAdjustSizeref=(gd,_ref6)=>{let{update}=_ref6;const{"marker.size":size=null,"marker.sizesrc":src=null}=update;if(size&&src){const DEFAULT_MAX_AREA_PX=45;const scaleFactor=DEFAULT_MAX_AREA_PX*DEFAULT_MAX_AREA_PX;update["marker.sizeref"]=size.reduce((a,b)=>Math.max(a,b))/scaleFactor;update["marker.sizemode"]="area"}};exports.shamefullyAdjustSizeref=shamefullyAdjustSizeref;const shamefullyAdjustAxisDirection=(gd,_ref7)=>{let{update}=_ref7;if(update.type==="funnel"&&gd.data.length===1){gd.layout.yaxis.autorange="reversed"}};exports.shamefullyAdjustAxisDirection=shamefullyAdjustAxisDirection;;(function(){var reactHotLoader=typeof reactHotLoaderGlobal!=="undefined"?reactHotLoaderGlobal.default:undefined;if(!reactHotLoader){return}reactHotLoader.register(shamefullyClearAxisTypes,"shamefullyClearAxisTypes","/react-chart-editor/src/shame.js");reactHotLoader.register(axLetters,"axLetters","/react-chart-editor/src/shame.js");reactHotLoader.register(clearAxisTypes,"clearAxisTypes","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustAxisRef,"shamefullyAdjustAxisRef","/react-chart-editor/src/shame.js");reactHotLoader.register(geoRegex,"geoRegex","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustGeo,"shamefullyAdjustGeo","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustMapbox,"shamefullyAdjustMapbox","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAddTableColumns,"shamefullyAddTableColumns","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustSplitStyleTargetContainers,"shamefullyAdjustSplitStyleTargetContainers","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyCreateSplitStyleProps,"shamefullyCreateSplitStyleProps","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyDeleteRelatedAnalysisTransforms,"shamefullyDeleteRelatedAnalysisTransforms","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustSizeref,"shamefullyAdjustSizeref","/react-chart-editor/src/shame.js");reactHotLoader.register(shamefullyAdjustAxisDirection,"shamefullyAdjustAxisDirection","/react-chart-editor/src/shame.js")})();;(function(){var leaveModule=typeof reactHotLoaderGlobal!=="undefined"?reactHotLoaderGlobal.leaveModule:undefined;leaveModule&&leaveModule(module)})();
//# sourceMappingURL=shame.js.map