chartUtils.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * 图形的工具类
  3. */
  4. import $ from 'jquery'
  5. import * as tools from '@/view/bireport/bireportUtils'
  6. export function findDimById(dimId, dims){
  7. var ret = null;
  8. if(!dims || dims == null){
  9. return ret;
  10. }
  11. for(var i=0; i<dims.length; i++){
  12. if(dims[i].id == dimId){
  13. ret = dims[i];
  14. break;
  15. }
  16. }
  17. return ret;
  18. }
  19. export function delChartKpiOrDim(tp, json, cb){
  20. if(tp == 'xcol'){
  21. delete json.chartJson.xcol;
  22. }
  23. if(tp == 'ycol'){
  24. json.chartJson.ycol = {};
  25. if(json.kpiJson.length > 1){
  26. json.kpiJson[0] = null;
  27. }else{
  28. json.kpiJson = [];
  29. }
  30. }
  31. if(tp == 'y2col'){
  32. if(json.kpiJson.length > 1){
  33. json.kpiJson[1] = null;
  34. }else{
  35. json.kpiJson = [];
  36. }
  37. }
  38. if(tp == 'y3col'){
  39. json.kpiJson[2] = null;
  40. }
  41. if(tp == 'scol'){
  42. delete json.chartJson.scol;
  43. }
  44. if(cb){
  45. cb();
  46. }
  47. }
  48. export function chartsort(sorttp, tp, json, cb){
  49. if(tp == 'xcol'){
  50. //清除度量排序,因为度量排序最优先
  51. delete json.kpiJson[0].sort;
  52. json.chartJson.xcol.dimord = sorttp;
  53. }
  54. if(tp == 'ycol'){
  55. json.kpiJson[0].sort = sorttp;
  56. }
  57. if(tp == 'scol'){
  58. //清除度量排序
  59. delete json.kpiJson[0].sort;
  60. json.chartJson.scol.dimord = sorttp;
  61. }
  62. if(cb){
  63. cb();
  64. }
  65. }