找文章 / 找答案
  • 发帖数1
  • 粉丝0

此人很懒,什么也没有留下

    精选问答 更多内容

    [可视化] 如何点击自定义JS绘图中数据联动表格数据

    yhdata_P8HODy1m新手上路 显示全部楼层 发表于 2024-7-6 18:05:41 |阅读模式 打印 上一主题 下一主题
    请教如何通过点击自定义绘图中的图形数据来联动表格中的数据,点击表格中的数据可以把参数暴露出来让表格接收么,谢谢~

    最佳答案

    永洪tech_xh 青铜一 关注Ta

    2024-07-06 18:05:42

    其中您需要修改部分window.location.replace('/bi/Viewer?proc=1&action=viewer&hback=true&db=公共/echarts/echarts!8d85!!94fe!!63a5!.db&platform=PC&browserType=chrome&wd=' + encodeURIComponent(params.name))为您对应的地址。 效果点击饼图,会将饼图所对应的地址通过wd参数传递给报告,进而您可以使用该参数对数据进行过滤。 点击益州后。 附件为上图报告样例 ...
    查看完整内容
    回复

    使用道具 举报

    精彩评论2

    永洪tech_xh青铜一 显示全部楼层 发表于 2024-7-6 18:05:42
    1. // 为保证正常绘图,代码格式与所选格式需保持一致;
    2. // 请输入JS代码或前往官网复制示例代码;
    3. // 复制完代码后,请先将代码中的数据列替换为绑定的数据列,绑定的数据列从上至下依次为column1、column2......,option部分请添加options.data以引用绑定列,chart绘制的DOM id会自动替换为变量$container
    4. var weatherIcons = {
    5. 'Sunny': './data/asset/img/weather/sunny_128.png',
    6. 'Cloudy': './data/asset/img/weather/cloudy_128.png',
    7. 'Showers': './data/asset/img/weather/showers_128.png'
    8. };

    9. //跳转代码
    10. myChart.on('click', function (params) {
    11. console.log(params.name);
    12. window.location.replace('/bi/Viewer?proc=1&action=viewer&hback=true&db=公共/echarts/echarts!8d85!!94fe!!63a5!.db&platform=PC&browserType=chrome&wd=' + encodeURIComponent(params.name))
    13. // window.open('http://localhost:8080/bi/Viewer?proc=1&action=viewer&hback=true&db=echarts!8d85!!94fe!!63a5!.db&platform=PC&browserType=chrome&wd=' + encodeURIComponent(params.name));

    14. });


    15. option = {
    16. title: {
    17. text: '天气情况统计',
    18. subtext: '虚构数据',
    19. left: 'center'
    20. },
    21. tooltip : {
    22. trigger: 'item',
    23. formatter: "{a} <br/>{b} : {c} ({d}%)"
    24. },
    25. legend: {
    26. // orient: 'vertical',
    27. // top: 'middle',
    28. bottom: 10,
    29. left: 'center',
    30. data: ['西凉', '益州','兖州','荆州','幽州']
    31. },
    32. series : [
    33. {
    34. type: 'pie',
    35. radius : '65%',
    36. center: ['50%', '50%'],
    37. selectedMode: 'single',
    38. data:[
    39. {
    40. value:1548,
    41. name: '幽州',
    42. label: {
    43. normal: {
    44. formatter: [
    45. '{title|{b}}{abg|}',
    46. ' {weatherHead|天气}{valueHead|天数}{rateHead|占比}',
    47. '{hr|}',
    48. ' {Sunny|}{value|202}{rate|55.3%}',
    49. ' {Cloudy|}{value|142}{rate|38.9%}',
    50. ' {Showers|}{value|21}{rate|5.8%}'
    51. ].join('\n'),
    52. backgroundColor: '#eee',
    53. borderColor: '#777',
    54. borderWidth: 1,
    55. borderRadius: 4,
    56. rich: {
    57. title: {
    58. color: '#eee',
    59. align: 'center'
    60. },
    61. abg: {
    62. backgroundColor: '#333',
    63. width: '100%',
    64. align: 'right',
    65. height: 25,
    66. borderRadius: [4, 4, 0, 0]
    67. },
    68. Sunny: {
    69. height: 30,
    70. align: 'left',
    71. backgroundColor: {
    72. image: weatherIcons.Sunny
    73. }
    74. },
    75. Cloudy: {
    76. height: 30,
    77. align: 'left',
    78. backgroundColor: {
    79. image: weatherIcons.Cloudy
    80. }
    81. },
    82. Showers: {
    83. height: 30,
    84. align: 'left',
    85. backgroundColor: {
    86. image: weatherIcons.Showers
    87. }
    88. },
    89. weatherHead: {
    90. color: '#333',
    91. height: 24,
    92. align: 'left'
    93. },
    94. hr: {
    95. borderColor: '#777',
    96. width: '100%',
    97. borderWidth: 0.5,
    98. height: 0
    99. },
    100. value: {
    101. width: 20,
    102. padding: [0, 20, 0, 30],
    103. align: 'left'
    104. },
    105. valueHead: {
    106. color: '#333',
    107. width: 20,
    108. padding: [0, 20, 0, 30],
    109. align: 'center'
    110. },
    111. rate: {
    112. width: 40,
    113. align: 'right',
    114. padding: [0, 10, 0, 0]
    115. },
    116. rateHead: {
    117. color: '#333',
    118. width: 40,
    119. align: 'center',
    120. padding: [0, 10, 0, 0]
    121. }
    122. }
    123. }
    124. }
    125. },
    126. {value:535, name: '荆州'},
    127. {value:510, name: '兖州'},
    128. {value:634, name: '益州'},
    129. {value:735, name: '西凉'}
    130. ],
    131. itemStyle: {
    132. emphasis: {
    133. shadowBlur: 10,
    134. shadowOffsetX: 0,
    135. shadowColor: 'rgba(0, 0, 0, 0.5)'
    136. }
    137. }
    138. }
    139. ]
    140. };
    复制代码
    其中您需要修改部分window.location.replace('/bi/Viewer?proc=1&action=viewer&hback=true&db=公共/echarts/echarts!8d85!!94fe!!63a5!.db&platform=PC&browserType=chrome&wd=' + encodeURIComponent(params.name))为您对应的地址。

    效果点击饼图,会将饼图所对应的地址通过wd参数传递给报告,进而您可以使用该参数对数据进行过滤。
    图片1.png
    点击益州后。
    图片2.png
    附件为上图报告样例

    echarts超链接样例.jar

    3.94 KB, 下载次数: 2

    回复

    使用道具 举报

    永洪tech_xh青铜一 显示全部楼层 发表于 2024-7-7 10:24:35
    产品无法将echarts组件的数据或值传递到报告中,但echart可以实现点击绘图中的某一部分进行页面跳转,您可以在echart代码编辑中,设置图片上的分块跳转到当前的报告,并传递参数。以此来达到数据联动的效果。
    回复

    使用道具 举报

    高级模式
    您需要登录后才可以回帖 登录 | 免费注册

    • 官方微信

      欢迎关注永洪服务号!收费为0,价值无限

      扫码关注
    • 新浪微博

      让每位用户轻松挖掘数据价值!

      访问新浪微博
    • 智能客服
    50W

    会员等你来哦

    Copyright   ©2012-2024  北京永洪商智科技有限公司  (京ICP备12050607) 京公网安备110110802011451号 |《永洪社区协议》
    返回顶部