123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- module.exports = {
- drawJobTimeLine:function (map, shuffle, reduce, w, h, element, legend_id, timeline_id) {
- map = $.parseJSON(map);
- shuffle = $.parseJSON(shuffle);
- reduce = $.parseJSON(reduce);
- if (!map || !shuffle || !reduce) {
- console.warn('drawJobTimeLine');
- return;
- }
- var graph = new Rickshaw.Graph({
- width:w,
- height:h,
- element:document.querySelector(element),
- renderer:'area',
- stroke:true,
- series:[
- {
- data:map,
- color:'green',
- name:'maps'
- },
- {
- data:shuffle,
- color:'lightblue',
- name:'shuffles'
- },
- {
- data:reduce,
- color:'steelblue',
- name:'reduces'
- }
- ]
- }
- );
- graph.render();
- var legend = new Rickshaw.Graph.Legend({
- graph:graph,
- element:document.getElementById(legend_id)
- });
- var shelving = new Rickshaw.Graph.Behavior.Series.Toggle({
- graph:graph,
- legend:legend
- });
- var order = new Rickshaw.Graph.Behavior.Series.Order({
- graph:graph,
- legend:legend
- });
- var highlight = new Rickshaw.Graph.Behavior.Series.Highlight({
- graph:graph,
- legend:legend
- });
- var xAxis = new Rickshaw.Graph.Axis.Time({
- graph:graph
- });
- xAxis.render();
- var yAxis = new Rickshaw.Graph.Axis.Y({
- graph:graph
- });
- yAxis.render();
- var hoverDetail = new Rickshaw.Graph.HoverDetail({
- graph:graph,
- yFormatter:function (y) {
- return Math.floor(y) + " tasks"
- }
- });
- var annotator = new Rickshaw.Graph.Annotate({
- graph:graph,
- element:document.getElementById(timeline_id)
- });
- },
- drawJobTasks:function (mapNodeLocal, mapRackLocal, mapOffSwitch, reduceOffSwitch, submitTime, w, h, element, legend_id, timeline_id) {
- mapNodeLocal = $.parseJSON(mapNodeLocal);
- mapRackLocal = $.parseJSON(mapRackLocal);
- mapOffSwitch = $.parseJSON(mapOffSwitch);
- reduceOffSwitch = $.parseJSON(reduceOffSwitch);
- if (!mapNodeLocal || !mapRackLocal || !mapOffSwitch || !reduceOffSwitch) {
- console.warn('drawJobTasks');
- return;
- }
- var graph = new Rickshaw.Graph({
- width:w,
- height:h,
- element:document.querySelector(element),
- renderer:'scatterplot',
- stroke:true,
- series:[
- {
- data:mapNodeLocal,
- color:'green',
- name:'node_local_map'
- },
- {
- data:mapRackLocal,
- color:'lightblue',
- name:'rack_local_map'
- },
- {
- data:mapOffSwitch,
- color:'brown',
- name:'off_switch_map'
- },
- {
- data:reduceOffSwitch,
- color:'red',
- name:'reduce'
- }
- ]
- });
- graph.render();
- var legend = new Rickshaw.Graph.Legend({
- graph:graph,
- element:document.getElementById(legend_id)
- });
- var shelving = new Rickshaw.Graph.Behavior.Series.Toggle({
- graph:graph,
- legend:legend
- });
- var order = new Rickshaw.Graph.Behavior.Series.Order({
- graph:graph,
- legend:legend
- });
- var highlight = new Rickshaw.Graph.Behavior.Series.Highlight({
- graph:graph,
- legend:legend
- });
- var ticksTreatment = 'glow';
- var xAxis = new Rickshaw.Graph.Axis.Time({
- graph:graph,
- ticksTreatment:ticksTreatment
- });
- xAxis.render();
- var yAxis = new Rickshaw.Graph.Axis.Y({
- graph:graph,
- ticksTreatment:ticksTreatment
- });
- yAxis.render();
- var hoverDetail = new Rickshaw.Graph.HoverDetail({
- graph:graph,
- xFormatter:function (x) {
- return (x - submitTime) + 's'
- },
- yFormatter:function (y) {
- return y / 1000 + 's'
- },
- formatter:function (series, x, y, formattedX, formattedY, d) {
- var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
- return swatch + (d.label? d.label: d.name) +
- '<br>Run-time: ' + formattedY + '<br>Wait-time: ' + formattedX;
- }
- });
- var annotator = new Rickshaw.Graph.Annotate({
- graph:graph,
- element:document.getElementById(timeline_id)
- });
- graph.update();
- }
- }
|