交互式图表

【交互式图表】该报表实现一个向下钻取的效果,主表是一个条形图显示整体信息,子表是一个明细表。

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReportsJS sample</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css" /> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-viewer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-designer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-pdf.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-xlsx.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/ar-js-locales.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/designer/zh-locale.js"></script> <script src="$DEMOROOT$/lib/purejs/license.js"></script> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-ui.css" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-viewer.css" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-designer.css" /> <style> #root { height: 100vh; } #viewer-host, #designer-host { height: 100%; } #designer-host { display: none; } </style> </head> <body onload="load()" style="margin: 0"> <div id="root"> <div id="viewer-host"></div> <div id="designer-host"></div> </div> <script> var currentReport = undefined; var viewerHost = document.getElementById("viewer-host"); var designerHost = document.getElementById("designer-host"); function load() { var viewer = new ActiveReports.Viewer("#viewer-host", { language: "zh", }); var designer = new GC.ActiveReports.ReportDesigner.Designer( "#designer-host", { language: "zh" } ); designer.setActionHandlers({ onRender(report) { currentReport = report.definition; viewer.open(currentReport); viewerHost.style.display = "block"; designerHost.style.display = "none"; // return Promise.resolve(); }, }); var designButton = { key: "$openDesigner", text: "编辑报表", iconCssClass: "mdi mdi-pencil", enabled: true, action: function (item) { designer.setReport({ definition: currentReport, displayName: "交互式报表", }); viewerHost.style.display = "none"; designerHost.style.display = "block"; }, }; viewer.toolbar.addItem(designButton); viewer.toolbar.updateLayout({ default: [ "$openDesigner", "$split", "$navigation", "$split", "$refresh", "$split", "$history", "$split", "$zoom", "$fullscreen", "$split", "$print", "$split", "$singlepagemode", "$continuousmode", "$galleymode", ], }); fetch("jiaohushitubiao.rdlx-json") .then(function (data) { return data.json(); }) .then(function (report) { currentReport = report; viewer.open(report); }); } </script> </body> </html>
{"Name":"Report","Width":"20.501cm","Layers":[{"Name":"default"}],"CustomProperties":[{"Name":"DisplayType","Value":"Page"},{"Name":"SizeType","Value":"Default"},{"Name":"PaperOrientation","Value":"Portrait"}],"Page":{"PageWidth":"21cm","PageHeight":"22cm","RightMargin":"0cm","LeftMargin":"0cm","TopMargin":"0cm","BottomMargin":"0cm","Columns":1,"ColumnSpacing":"0in"},"DataSources":[{"Name":"DataSource","ConnectionProperties":{"DataProvider":"JSONEMBED","ConnectString":"jsondata=[\\r\\n {\\r\\n \"类别名称\": \"饮料\",\\r\\n \"类别ID\": 1,\\r\\n \"销售量\": 3996\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"调味品\",\\r\\n \"类别ID\": 2,\\r\\n \"销售量\": 2875\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"点心\",\\r\\n \"类别ID\": 3,\\r\\n \"销售量\": 4157\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"日用品\",\\r\\n \"类别ID\": 4,\\r\\n \"销售量\": 4374\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"谷类/麦片\",\\r\\n \"类别ID\": 5,\\r\\n \"销售量\": 2636\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"肉/家禽\",\\r\\n \"类别ID\": 6,\\r\\n \"销售量\": 2189\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"特制品\",\\r\\n \"类别ID\": 7,\\r\\n \"销售量\": 1583\\r\\n },\\r\\n {\\r\\n \"类别名称\": \"海鲜\",\\r\\n \"类别ID\": 8,\\r\\n \"销售量\": 3679\\r\\n }\\r\\n]"}}],"Body":{"Height":"20.5cm","ReportItems":[{"Type":"dvchart","Name":"图表1","DataSetName":"DataSet","Style":{"FontFamily":"微软雅黑","PaddingLeft":"2pt","PaddingRight":"2pt","PaddingTop":"2pt","PaddingBottom":"2pt"},"Bar":{"BottomWidth":0.7,"TopWidth":0.7,"Width":0.7},"Header":{"Style":{"PaddingTop":"4pt","PaddingBottom":"2pt"},"TextStyle":{"FontFamily":"微软雅黑","FontSize":"20pt","FontWeight":"Bold","Color":"#2f2f2f"},"Title":"年度各类产品销量统计表"},"Footer":{"Style":{"PaddingTop":"2pt","PaddingBottom":"4pt"},"TextStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f"}},"Legend":{"Orientation":"Vertical","Style":{"PaddingRight":"5pt"},"TextStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f"},"TitleStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f"},"Wrapping":true},"PlotArea":{"Axes":[{"Format":"","LabelStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f","PaddingTop":"3pt","PaddingBottom":"3pt"},"LineStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"MajorGridStyle":{"Border":{"Color":"#d2d2d2","Style":"Solid","Width":"0.5pt"}},"MajorTicks":"Outside","MajorTickSize":"0.2pt","MajorTickStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"MinorGridStyle":{"Border":{"Color":"#e6e6e6","Style":"Solid","Width":"0.5pt"}},"MinorTickSize":"0.1pt","MinorTickStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"Plots":["绘图区域 1"],"TitleStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f","PaddingLeft":"2pt","PaddingRight":"2pt","PaddingTop":"2pt","PaddingBottom":"2pt"}},{"AxisType":"Y","Format":"","LabelStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f","PaddingLeft":"3pt","PaddingRight":"3pt"},"LineStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"MajorGrid":true,"MajorGridStyle":{"Border":{"Color":"#d2d2d2","Style":"Solid","Width":"0.5pt"}},"MajorTicks":"Outside","MajorTickSize":"0.2pt","MajorTickStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"MinorGridStyle":{"Border":{"Color":"#e6e6e6","Style":"Solid","Width":"0.5pt"}},"MinorTickSize":"0.1pt","MinorTickStyle":{"Border":{"Color":"#666666","Style":"Solid","Width":"0.5pt"}},"Plots":["绘图区域 1"],"TitleStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f","PaddingLeft":"2pt","PaddingRight":"2pt","PaddingTop":"2pt","PaddingBottom":"2pt"}}],"Legends":[{"Orientation":"Vertical","Style":{"PaddingRight":"5pt"},"TextStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f"},"TitleStyle":{"FontFamily":"微软雅黑","Color":"#2f2f2f"}}]},"Plots":[{"PlotName":"绘图区域 1","Encodings":{"Values":[{"Field":{"FieldType":"Simple","Value":["=sum(Fields!销售量.Value)",""]}}],"Category":{"Field":{"FieldType":"Simple","Value":["=Fields!类别名称.Value"]}},"Color":{"Field":{"FieldType":"Simple"}},"Shape":{"Field":{"FieldType":"Simple"}},"Size":{"Field":{"FieldType":"Simple"}}},"Config":{"Action":{"Drillthrough":{"ReportName":"jiaohushitubiaozibaobiao.rdlx-json","Parameters":[{"ParameterName":"CategoryID","Value":"=Fields!类别ID.Value"},{"ParameterName":"CategoryName","Value":"=Fields!类别名称.Value"}]}},"LineStyle":{"Style":"None","Width":"1pt"},"Opacity":0.8,"SwapAxes":true,"Text":{"Template":"{valueField.value}","Style":{"FontFamily":"微软雅黑","Color":"#2f2f2f"}}},"PlotChartType":"Bar","PlotChartSubtype":"Clustered"}],"Left":"0.501cm","Top":"3cm","Width":"20cm","Height":"17.5cm"}]},"DataSets":[{"Name":"DataSet","Fields":[{"Name":"类别名称","DataField":"类别名称"},{"Name":"类别ID","DataField":"类别ID"},{"Name":"销售量","DataField":"销售量"}],"Query":{"DataSourceName":"DataSource","CommandText":"jpath=$.[*]"},"CaseSensitivity":"Auto","KanatypeSensitivity":"Auto","AccentSensitivity":"Auto","WidthSensitivity":"Auto"}]}