123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <html>
- <head>
- <meta charset="utf-8">
- <script src="esl.js"></script>
- <script src="config.js"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- </head>
- <body>
- <style>
- html, body, #main {
- width: 100%;
- height: 100%;
- margin: 0;
- padding: 0;
- }
- .controller {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- background: #fff;
- border-bottom: 1px solid #ccc;
- line-height: 30px;
- z-index: 100;
- }
- .controller label {
- margin-right: 10px;
- }
- .item-title {
- font-weight: bold;
- }
- .controller .item {
- margin-right: 20px;
- padding-right: 10px;
- border-right: 1px solid #ccc;
- }
- .tooltip-title {
- color: yellow;
- font-size: 16px;
- margin-bottom: 5px;
- }
- </style>
- <div class="controller">
- <span class="item">
- <span class="item-title">childrenVisibleMin:</span>
- <input type="radio" id="childrenVisibleMin-0" name="childrenVisibleMin" onclick="childrenVisibleMinChange(0);" checked="checked"/>
- <label for="childrenVisibleMin-0">0</label>
- <input type="radio" id="childrenVisibleMin-1" name="childrenVisibleMin" onclick="childrenVisibleMinChange(1000000);"/>
- <label for="childrenVisibleMin-1">1000000</label>
- </span>
- <span class="item">
- <span class="item-title">colorMapping:</span>
- <input type="radio" id="colorMapping-0" name="colorMapping" onclick="colorMappingChange('index');" checked="checked"/>
- <label for="colorMapping-0">byIndex</label>
- <input type="radio" id="colorMapping-1" name="colorMapping" onclick="colorMappingChange('value');"/>
- <label for="colorMapping-1">byValue</label>
- </span>
- <span class="item">
- <span class="item-title">leafDepth:</span>
- <input type="radio" id="leafDepth-0" name="leafDepth" onclick="leafDepthChange(null);" checked="checked"/>
- <label for="leafDepth-0">Not set</label>
- <input type="radio" id="leafDepth-1" name="leafDepth" onclick="leafDepthChange(1);"/>
- <label for="leafDepth-1">Set to 1</label>
- <input type="radio" id="leafDepth-2" name="leafDepth" onclick="leafDepthChange(2);"/>
- <label for="leafDepth-1">Set to 2</label>
- </span>
- </div>
- <div id="main"></div>
- <script src="data/disk.tree.js"></script>
- <script>
- var chart;
- var formatUtil;
- require([
- 'echarts',
- 'echarts/util/format',
- 'echarts/component/tooltip',
- 'echarts/component/legend',
- 'echarts/chart/treemap'
- ], function (echarts, format) {
- formatUtil = format;
- initEcharts(echarts);
- });
- function childrenVisibleMinChange(value) {
- chart.setOption({
- series: [{
- childrenVisibleMin: value
- }]
- });
- }
- function colorMappingChange(value) {
- var levelOption = getLevelOption(value);
- chart.setOption({
- series: [{
- levels: levelOption
- }]
- });
- }
- function leafDepthChange(value) {
- chart.setOption({
- series: [{
- leafDepth: value
- }]
- });
- }
- function getLevelOption(colorMapping) {
- return [
- {
- color: ['#d14a61'], // default color
- itemStyle: {
- normal: {
- borderWidth: 0,
- gapWidth: 5
- }
- }
- },
- {
- color: [
- '#d14a61', '#fd9c35',
- '#675bba', '#fec42c', '#dd4444',
- '#d4df5a', '#cd4870'
- ],
- colorMappingBy: colorMapping,
- itemStyle: {
- normal: {
- gapWidth: 1
- }
- }
- },
- {
- colorSaturation: [0.35, 0.5],
- itemStyle: {
- normal: {
- gapWidth: 1,
- borderColorSaturation: 0.6
- }
- }
- }
- ];
- }
- function initEcharts(echarts) {
- chart = echarts.init(document.getElementById('main'), null, {
- renderer: 'canvas'
- });
- chart.setOption({
- tooltip: {
- formatter: function (info) {
- var value = info.value;
- var treePathInfo = info.treePathInfo;
- var treePath = [];
- for (var i = 1; i < treePathInfo.length; i++) {
- treePath.push(treePathInfo[i].name);
- }
- return [
- '<div class="tooltip-title">' + formatUtil.encodeHTML(treePath.join('/')) + '</div>',
- 'Disk Usage: ' + formatUtil.addCommas(value) + ' KB',
- ].join('');
- }
- },
- series: [
- {
- name:'Disk Usage',
- type:'treemap',
- visibleMin: 300,
- // childrenVisibleMin: 500000,
- label: {
- show: true,
- formatter: '{b}'
- // normal: {
- // textStyle: {
- // color: 'black'
- // }
- // }
- },
- itemStyle: {
- normal: {
- borderColor: '#fff'
- },
- emphasis: {
- }
- },
- levels: getLevelOption('index'),
- data: window.disk_usage_tree
- }
- ]
- });
- chart.on('click', function (params) {
- console.log(params);
- });
- }
- </script>
- </body>
- </html>
|