diff options
author | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-11-21 00:46:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-11-21 00:46:35 +0000 |
commit | 174b299271189496bae4c4d6727ea26a7a098756 (patch) | |
tree | b063e18c795988e38e1eb4afa74d4cbf9524f057 /utils/test/reporting/js | |
parent | fd65ec9e84ae025e6b903c403514405ba0bb0a61 (diff) | |
parent | f11f26d23dabde24b0bcd67ac81b094aa89eb6c9 (diff) |
Merge "Remove 'utils/test' Directory and update INFO"
Diffstat (limited to 'utils/test/reporting/js')
-rw-r--r-- | utils/test/reporting/js/gauge.js | 165 | ||||
-rw-r--r-- | utils/test/reporting/js/trend-qtip.js | 76 | ||||
-rw-r--r-- | utils/test/reporting/js/trend.js | 75 |
3 files changed, 0 insertions, 316 deletions
diff --git a/utils/test/reporting/js/gauge.js b/utils/test/reporting/js/gauge.js deleted file mode 100644 index 4cad16c61..000000000 --- a/utils/test/reporting/js/gauge.js +++ /dev/null @@ -1,165 +0,0 @@ -// ****************************************** -// Gauge for reporting -// Each scenario has a score -// We use a gauge to indicate the trust level -// ****************************************** -var gauge = function(container) { - var that = {}; - var config = { - size : 150, - clipWidth : 250, - clipHeight : 100, - ringInset : 20, - ringWidth : 40, - - pointerWidth : 7, - pointerTailLength : 5, - pointerHeadLengthPercent : 0.8, - - minValue : 0, - maxValue : 100, - - minAngle : -90, - maxAngle : 90, - - transitionMs : 4000, - - majorTicks : 7, - labelFormat : d3.format(',g'), - labelInset : 10, - - arcColorFn : d3.interpolateHsl(d3.rgb('#ff0000'), d3.rgb('#00ff00')) - }; - - -var range = undefined; -var r = undefined; -var pointerHeadLength = undefined; -var value = 0; - -var svg = undefined; -var arc = undefined; -var scale = undefined; -var ticks = undefined; -var tickData = undefined; -var pointer = undefined; - -var donut = d3.layout.pie(); - -function deg2rad(deg) { - return deg * Math.PI / 180; -} - -function newAngle(d) { - var ratio = scale(d); - var newAngle = config.minAngle + (ratio * range); - return newAngle; -} - -function configure() { - range = config.maxAngle - config.minAngle; - r = config.size / 2; - pointerHeadLength = Math.round(r * config.pointerHeadLengthPercent); - - // a linear scale that maps domain values to a percent from 0..1 - scale = d3.scale.linear() - .range([0,1]) - .domain([config.minValue, config.maxValue]); - - ticks = scale.ticks(config.majorTicks); - tickData = d3.range(config.majorTicks).map(function() {return 1/config.majorTicks;}); - - arc = d3.svg.arc() - .innerRadius(r - config.ringWidth - config.ringInset) - .outerRadius(r - config.ringInset) - .startAngle(function(d, i) { - var ratio = d * i; - return deg2rad(config.minAngle + (ratio * range)); - }) - .endAngle(function(d, i) { - var ratio = d * (i+1); - return deg2rad(config.minAngle + (ratio * range)); - }); -} -that.configure = configure; - -function centerTranslation() { - return 'translate('+r +','+ r +')'; -} - -function isRendered() { - return (svg !== undefined); -} -that.isRendered = isRendered; - -function render(newValue) { - svg = d3.select(container) - .append('svg:svg') - .attr('class', 'gauge') - .attr('width', config.clipWidth) - .attr('height', config.clipHeight); - - var centerTx = centerTranslation(); - - var arcs = svg.append('g') - .attr('class', 'arc') - .attr('transform', centerTx); - - arcs.selectAll('path') - .data(tickData) - .enter().append('path') - .attr('fill', function(d, i) { - return config.arcColorFn(d * i); - }) - .attr('d', arc); - - var lg = svg.append('g') - .attr('class', 'label') - .attr('transform', centerTx); - lg.selectAll('text') - .data(ticks) - .enter().append('text') - .attr('transform', function(d) { - var ratio = scale(d); - var newAngle = config.minAngle + (ratio * range); - return 'rotate(' +newAngle +') translate(0,' +(config.labelInset - r) +')'; - }) - .text(config.labelFormat); - - var lineData = [ [config.pointerWidth / 2, 0], - [0, -pointerHeadLength], - [-(config.pointerWidth / 2), 0], - [0, config.pointerTailLength], - [config.pointerWidth / 2, 0] ]; - var pointerLine = d3.svg.line().interpolate('monotone'); - var pg = svg.append('g').data([lineData]) - .attr('class', 'pointer') - .attr('transform', centerTx); - - pointer = pg.append('path') - .attr('d', pointerLine/*function(d) { return pointerLine(d) +'Z';}*/ ) - .attr('transform', 'rotate(' +config.minAngle +')'); - - update(newValue === undefined ? 0 : newValue); -} -that.render = render; - -function update(newValue, newConfiguration) { - if ( newConfiguration !== undefined) { - configure(newConfiguration); - } - var ratio = scale(newValue); - var newAngle = config.minAngle + (ratio * range); - pointer.transition() - .duration(config.transitionMs) - .ease('elastic') - .attr('transform', 'rotate(' +newAngle +')'); -} -that.update = update; - -configure(); - -render(); - -return that; -}; diff --git a/utils/test/reporting/js/trend-qtip.js b/utils/test/reporting/js/trend-qtip.js deleted file mode 100644 index d4c8735d9..000000000 --- a/utils/test/reporting/js/trend-qtip.js +++ /dev/null @@ -1,76 +0,0 @@ -// ****************************************** -// Trend line for reporting -// based on scenario_history.txt -// where data looks like -// date,scenario,installer,detail,score -// 2016-09-22 13:12,os-nosdn-fdio-noha,apex,4/12,33.0 -// 2016-09-22 13:13,os-odl_l2-fdio-noha,apex,12/15,80.0 -// 2016-09-22 13:13,os-odl_l2-sfc-noha,apex,18/24,75.0 -// ..... -// ****************************************** -// Set the dimensions of the canvas / graph -var trend_margin = {top: 20, right: 30, bottom: 50, left: 40}, - trend_width = 300 - trend_margin.left - trend_margin.right, - trend_height = 130 - trend_margin.top - trend_margin.bottom; - -// Parse the date / time -var parseDate = d3.time.format("%Y-%m-%d %H:%M").parse; - -// Set the ranges -var trend_x = d3.time.scale().range([0, trend_width]); -var trend_y = d3.scale.linear().range([trend_height, 0]); - -// Define the axes -var trend_xAxis = d3.svg.axis().scale(trend_x) - .orient("bottom").ticks(2).tickFormat(d3.time.format("%m-%d")); - -var trend_yAxis = d3.svg.axis().scale(trend_y) - .orient("left").ticks(4, "s"); - -// Define the line -var valueline = d3.svg.line() - .x(function(d) { return trend_x(d.date); }) - .y(function(d) { return trend_y(d.score); }); - -var trend = function(container, trend_data) { - - var trend_svg = d3.select(container) - .append("svg") - .attr("width", trend_width + trend_margin.left + trend_margin.right) - .attr("height", trend_height + trend_margin.top + trend_margin.bottom) - .attr("style", "font-size: small") - .append("g") - .attr("transform", - "translate(" + trend_margin.left + "," + trend_margin.top + ")"); - - // Scale the range of the data - trend_x.domain(d3.extent(trend_data, function(d) { return d.date; })); - trend_y.domain([0, d3.max(trend_data, function(d) { return d.score; })]); - - // Add the X Axis - trend_svg.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + trend_height + ")") - .call(trend_xAxis); - - // Add the Y Axis - trend_svg.append("g") - .attr("class", "y axis") - .call(trend_yAxis); - - // Add the valueline path. - trend_svg.append("path") - .attr("class", "line") - .attr("d", valueline(trend_data)) - .attr("stroke", "steelblue") - .attr("fill", "none"); - - trend_svg.selectAll(".dot") - .data(trend_data) - .enter().append("circle") - .attr("r", 2.5) - .attr("cx", function(d) { return trend_x(d.date); }) - .attr("cy", function(d) { return trend_y(d.score); }); - - return trend; -} diff --git a/utils/test/reporting/js/trend.js b/utils/test/reporting/js/trend.js deleted file mode 100644 index f24213382..000000000 --- a/utils/test/reporting/js/trend.js +++ /dev/null @@ -1,75 +0,0 @@ -// ****************************************** -// Trend line for reporting -// based on scenario_history.txt -// where data looks like -// date,scenario,installer,detail,score -// 2016-09-22 13:12,os-nosdn-fdio-noha,apex,4/12,33.0 -// 2016-09-22 13:13,os-odl_l2-fdio-noha,apex,12/15,80.0 -// 2016-09-22 13:13,os-odl_l2-sfc-noha,apex,18/24,75.0 -// ..... -// ****************************************** -// Set the dimensions of the canvas / graph -var trend_margin = {top: 20, right: 30, bottom: 50, left: 40}, - trend_width = 300 - trend_margin.left - trend_margin.right, - trend_height = 130 - trend_margin.top - trend_margin.bottom; - -// Parse the date / time -var parseDate = d3.time.format("%Y-%m-%d %H:%M").parse; - -// Set the ranges -var trend_x = d3.time.scale().range([0, trend_width]); -var trend_y = d3.scale.linear().range([trend_height, 0]); - -// Define the axes -var trend_xAxis = d3.svg.axis().scale(trend_x) - .orient("bottom").ticks(2).tickFormat(d3.time.format("%m-%d")); - -var trend_yAxis = d3.svg.axis().scale(trend_y) - .orient("left").ticks(2); - -// Define the line -var valueline = d3.svg.line() - .x(function(d) { return trend_x(d.date); }) - .y(function(d) { return trend_y(d.score); }); - -var trend = function(container, trend_data) { - - var trend_svg = d3.select(container) - .append("svg") - .attr("width", trend_width + trend_margin.left + trend_margin.right) - .attr("height", trend_height + trend_margin.top + trend_margin.bottom) - .append("g") - .attr("transform", - "translate(" + trend_margin.left + "," + trend_margin.top + ")"); - - // Scale the range of the data - trend_x.domain(d3.extent(trend_data, function(d) { return d.date; })); - trend_y.domain([0, d3.max(trend_data, function(d) { return d.score; })]); - - // Add the X Axis - trend_svg.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + trend_height + ")") - .call(trend_xAxis); - - // Add the Y Axis - trend_svg.append("g") - .attr("class", "y axis") - .call(trend_yAxis); - - // Add the valueline path. - trend_svg.append("path") - .attr("class", "line") - .attr("d", valueline(trend_data)) - .attr("stroke", "steelblue") - .attr("fill", "none"); - - trend_svg.selectAll(".dot") - .data(trend_data) - .enter().append("circle") - .attr("r", 2.5) - .attr("cx", function(d) { return trend_x(d.date); }) - .attr("cy", function(d) { return trend_y(d.score); }); - - return trend; -} |