staticdataold.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. location.hash = '#/chart/preview/1';
  2. window.location.replace(window.location.href.toString().replace(window.location.hash, '')+'#/chart/preview/1');
  3. $('link[href^="/theme/zui/css"]').remove();
  4. $('link[href^="/theme/default/style.css"]').remove();
  5. function setStaticData(staticData, options)
  6. {
  7. staticData = JSON.parse(staticData);
  8. let radio = 1;
  9. if(options.width)
  10. {
  11. const originalWidth = staticData.editCanvasConfig.width;
  12. staticData.editCanvasConfig.width = options.width;
  13. radio = options.width / originalWidth;
  14. }
  15. staticData.componentList = staticData.componentList.map(component => {
  16. component.attr.w = component.attr.w * radio;
  17. component.attr.h = component.attr.h * radio;
  18. component.attr.x = component.attr.x * radio;
  19. component.attr.y = component.attr.y * radio;
  20. if(component.option?.paddingX)
  21. {
  22. component.option.paddingX = component.option.paddingX * radio;
  23. }
  24. if(component.option?.paddingY)
  25. {
  26. component.option.paddingY = component.option.paddingY * radio;
  27. }
  28. return component;
  29. });
  30. window.staticData = staticData;
  31. let script = document.createElement('script');
  32. script.type = 'module';
  33. script.crossorigin = true;
  34. script.src = webRoot + 'static/js/index.js';
  35. document.head.appendChild(script);
  36. }