2017-10-18 78 views
0

我想呈现一个图表,显示当前正在进行的项目的进度。所以基本上一旦你打开了这个图,它会向你显示一个Passed,Failed的图,而不是在一个堆积区运行测试。
Highcharts:堆叠区域深入到多个系列

我想钻取主要数据(通过,失败,未运行)。我想基本显示可能已经通过,失败或未运行的团队。假设你想深入了解“通过”,一旦你点击“通过”,它应该带来多个系列,每个系列包含团队名称和通过测试的数量。

JSfiddle: https://jsfiddle.net/9aqbLzar/3/ 

演示:

Highcharts.Tick.prototype.drillable = function() {}; 
 
Highcharts.setOptions({ 
 
    lang: { 
 
    drillUpText: '◁ Go back' 
 
    } 
 
}); 
 

 
Highcharts.chart('container', { 
 
    chart: { 
 
    type: 'area' 
 
    }, 
 
    xAxis: { 
 
    type: 'datetime', 
 
    tickmarkPlacement: 'on', 
 
    title: { 
 
     enabled: false 
 
    } 
 
    }, 
 
    yAxis: { 
 
    allowDecimals: false, 
 
    title: { 
 
     text: "Test runs" 
 
    } 
 
    }, 
 
    tooltip: { 
 
    shared: false 
 
    }, 
 
    plotOptions: { 
 
    area: { 
 
     stacking: 'normal', 
 
     lineColor: null, 
 
     lineWidth: 1, 
 
     marker: { 
 
     enabled: false, 
 
     lineWidth: 1, 
 
     lineColor: null, 
 
     symbol: 'circle', 
 
     radius: 3 
 
     } 
 
    }, 
 
    cursor: 'pointer', 
 
    trackByArea: true 
 
    }, 
 
    series: [{ 
 
     name: 'Passed', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 06), 
 
     y: 20, 
 
     drilldown: 'Passed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 07), 
 
     y: 21, 
 
     drilldown: 'Passed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 08), 
 
     y: 22, 
 
     drilldown: 'Passed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 09), 
 
     y: 23, 
 
     drilldown: 'Passed' 
 
     }] 
 
    }, 
 
    { 
 
     name: 'Failed', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 06), 
 
     y: 6, 
 
     drilldown: 'Failed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 07), 
 
     y: 5, 
 
     drilldown: 'Failed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 08), 
 
     y: 4, 
 
     drilldown: 'Failed' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 09), 
 
     y: 3, 
 
     drilldown: 'Failed' 
 
     }] 
 
    }, 
 
    { 
 
     name: 'Not run', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 06), 
 
     y: 8, 
 
     drilldown: 'Not run' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 07), 
 
     y: 7, 
 
     drilldown: 'Not run' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 08), 
 
     y: 6, 
 
     drilldown: 'Not run' 
 
     }, { 
 
     x: Date.UTC(2017, 09, 09), 
 
     y: 5, 
 
     drilldown: 'Not run' 
 
     }] 
 
    } 
 
    ], 
 
    drilldown: { 
 
    series: [{ 
 
     id: 'Passed', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 11), 
 
     y: 1 
 
     }, { 
 
     x: Date.UTC(2017, 09, 12), 
 
     y: 2 
 
     }, { 
 
     x: Date.UTC(2017, 09, 13), 
 
     y: 3 
 
     }, { 
 
     x: Date.UTC(2017, 10, 14), 
 
     y: 5 
 
     }] 
 
    }, { 
 
     id: 'Failed', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 09), 
 
     y: 5 
 
     }, { 
 
     x: Date.UTC(2017, 09, 10), 
 
     y: 6 
 
     }, { 
 
     x: Date.UTC(2017, 09, 11), 
 
     y: 7 
 
     }, { 
 
     x: Date.UTC(2017, 10, 12), 
 
     y: 8 
 
     }, { 
 
     x: Date.UTC(2017, 10, 13), 
 
     y: 9 
 
     }] 
 
    }, { 
 
     id: 'Not run', 
 
     data: [{ 
 
     x: Date.UTC(2017, 09, 09), 
 
     y: 5 
 
     }, { 
 
     x: Date.UTC(2017, 09, 10), 
 
     y: 6 
 
     }, { 
 
     x: Date.UTC(2017, 09, 11), 
 
     y: 7 
 
     }, { 
 
     x: Date.UTC(2017, 10, 12), 
 
     y: 8 
 
     }, { 
 
     x: Date.UTC(2017, 10, 13), 
 
     y: 9 
 
     }] 
 
    }] 
 
    } 
 
});
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/modules/exporting.js"></script> 
 
<script src="https://code.highcharts.com/modules/drilldown.js"></script> 
 

 
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

+0

我已经包含的代码片段选项堆栈溢出报价中你的代码。其他用户更容易将其包含在他们的答案中,并避免链接到像jsfiddle.net这样的外部网站。 – tgogos

+0

@tgogos - 使用代码片段选项堆栈溢出优惠很好,但使用'jsfiddle'操作和播放要容易很多倍。 – ewolden

回答

2

首先,你需要有多个钻系列的每个系列(如三为 '通过',三为“失败','不运行'的三个)。其次,深入研究多个系列的唯一方法是使用名为addSingleSeriesAsDrilldown的函数将它们添加到drilldown事件中。当需要添加系列时,您只需要使用applyDrilldown函数。看看下面的例子,如果有任何问题,请随时询问。

API参考:
https://api.highcharts.com/highcharts/chart.events.drilldown

例子:
https://jsfiddle.net/7a6gh7vz/

+0

您好,真棒! – Uthman