Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break out legend into a separate HTML element and adjust chart widths #15

Merged
merged 1 commit into from
Sep 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const backgroundColors = ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)',
'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ];
const borderColors = ['rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)'];
export const lineWidthInPixels = 2;
export const lineWidthInPixels = 1;
export const pointRadiusInPixels = 0.5;
var backgroundColorMap = {}
var borderColorMap = {}
Expand Down
58 changes: 50 additions & 8 deletions client/components/CompletedGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
:chart-data="datacollection"
:options="{
responsive: true,
maintainAspectRatio: false,
maintainAspectRatio: true,
title: {
display: false,
text: 'Completed'
},
legend: {
display: true,
position: 'left'
},
display: false,
},
animation: {
duration:0 // turn off annoying bouncing animation
},
Expand All @@ -34,7 +33,7 @@
import { eventBus } from '../client';
import { getBackgroundColorFor, getBorderColorFor, lineWidthInPixels, pointRadiusInPixels} from '../client';
import { truncate} from '../pages/utilities.js';

export default {
components: {
LineChart,
Expand All @@ -49,7 +48,7 @@
}
},
mounted () {
//this.updateChart()
//this.updateChart();
},
methods: {
updateChart () {
Expand All @@ -59,8 +58,9 @@
this.datacollection["datasets"]=[];
for (var thisPath in this.stats.FunctionStatsMap){
var dataSetForPath = {
label: truncate(thisPath,15) + ": "+ this.stats.FunctionStatsMap[thisPath].Complete,
backgroundColor: getBackgroundColorFor(thisPath),
label: thisPath + ": "+ this.stats.FunctionStatsMap[thisPath].Complete,
fill: false, // Only use fill if chart is stacked
backgroundColor: 'white', // needed if fill is false to set fill color in legend
borderColor: getBorderColorFor(thisPath),
borderWidth: lineWidthInPixels,
radius:pointRadiusInPixels,
Expand All @@ -69,6 +69,26 @@
this.datacollection["datasets"].push(dataSetForPath);

}
var legs = document.getElementById("completedGraphLegend");

// legend
var text = [];
text.push('<ul class=\'' + 'chartLegend\'>');
var chartDataDatasets = this.datacollection["datasets"];
var chartDataDatasetsLength = chartDataDatasets.length;
for (var i = 0; i < chartDataDatasets.length; i++) {
text.push('<li><span class=\'chartLabelEmblem\' style=\'' +
'background-color:' + chartDataDatasets[i].backgroundColor + '; ' +
'border-color:' + chartDataDatasets[i].borderColor + ';' +
'\'></span>');
if (chartDataDatasets[i].label) {
text.push('<span class=\'chartLabelText\'>'+chartDataDatasets[i].label+'</span>');
}
text.push('</li>');
}
text.push('</ul>');
legs.innerHTML = text.join('');
// end of legend
}
}
},
Expand All @@ -83,4 +103,26 @@
</script>

<style>
.chartLegend{
}
.chartLabelEmblem {
float:left;
width:40px;
height:14px;
line-height:20px;
margin-top:3px;
margin-left:10px;
margin-right:6px;
border:1px solid;
font-size:8px;
}
.chartLabelText {
font-size:14px;
}

ul.chartLegend{
margin-right:10px;
list-style-type: none;
padding-left:0px;
}
</style>
58 changes: 50 additions & 8 deletions client/components/FailedGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
:chart-data="datacollection"
:options="{
responsive: true,
maintainAspectRatio: false,
maintainAspectRatio: true,
title: {
display: false,
text: 'Failed'
},
legend: {
display: true,
position: 'left'
},
display: false,
},
animation: {
duration:0 // turn off annoying bouncing animation
},
Expand All @@ -34,7 +33,7 @@
import { eventBus } from '../client';
import { getBackgroundColorFor, getBorderColorFor, lineWidthInPixels, pointRadiusInPixels} from '../client';
import { truncate} from '../pages/utilities.js';

export default {
components: {
LineChart,
Expand All @@ -49,7 +48,7 @@
}
},
mounted () {
//this.updateChart()
//this.updateChart();
},
methods: {
updateChart () {
Expand All @@ -59,8 +58,9 @@
this.datacollection["datasets"]=[];
for (var thisPath in this.stats.FunctionStatsMap){
var dataSetForPath = {
label: truncate(thisPath,15) + ": "+ this.stats.FunctionStatsMap[thisPath].Failed,
backgroundColor: getBackgroundColorFor(thisPath),
label: thisPath + ": "+ this.stats.FunctionStatsMap[thisPath].Failed,
fill: false, // Only use fill if chart is stacked
backgroundColor: 'white', // needed if fill is false to set fill color in legend
borderColor: getBorderColorFor(thisPath),
borderWidth: lineWidthInPixels,
radius:pointRadiusInPixels,
Expand All @@ -69,6 +69,26 @@
this.datacollection["datasets"].push(dataSetForPath);

}
var legs = document.getElementById("failedGraphLegend");

// legend
var text = [];
text.push('<ul class=\'' + 'chartLegend\'>');
var chartDataDatasets = this.datacollection["datasets"];
var chartDataDatasetsLength = chartDataDatasets.length;
for (var i = 0; i < chartDataDatasets.length; i++) {
text.push('<li><span class=\'chartLabelEmblem\' style=\'' +
'background-color:' + chartDataDatasets[i].backgroundColor + '; ' +
'border-color:' + chartDataDatasets[i].borderColor + ';' +
'\'></span>');
if (chartDataDatasets[i].label) {
text.push('<span class=\'chartLabelText\'>'+chartDataDatasets[i].label+'</span>');
}
text.push('</li>');
}
text.push('</ul>');
legs.innerHTML = text.join('');
// end of legend
}
}
},
Expand All @@ -83,4 +103,26 @@
</script>

<style>
.chartLegend{
}
.chartLabelEmblem {
float:left;
width:40px;
height:14px;
line-height:20px;
margin-top:3px;
margin-left:10px;
margin-right:6px;
border:1px solid;
font-size:8px;
}
.chartLabelText {
font-size:14px;
}

ul.chartLegend{
margin-right:10px;
list-style-type: none;
padding-left:0px;
}
</style>
60 changes: 51 additions & 9 deletions client/components/QueuedGraph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
:chart-data="datacollection"
:options="{
responsive: true,
maintainAspectRatio: false,
maintainAspectRatio: true,
title: {
display: false,
text: 'Queued'
},
legend: {
display: true,
position: 'left'
},
display: false,
},
animation: {
duration:0 // turn off annoying bouncing animation
},
scales: {
yAxes: [{
stacked: false, // QueuedGraph is not stacked
stacked: false, // QueuedGraph is not stacked
ticks: {
suggestedMax: 10
suggestedMax: 10
}
}]
}
Expand All @@ -34,7 +33,7 @@
import { eventBus } from '../client';
import { getBackgroundColorFor, getBorderColorFor, lineWidthInPixels, pointRadiusInPixels} from '../client';
import { truncate} from '../pages/utilities.js';

export default {
components: {
LineChart,
Expand All @@ -49,7 +48,7 @@
}
},
mounted () {
//this.updateChart()
//this.updateChart();
},
methods: {
updateChart () {
Expand All @@ -59,7 +58,7 @@
this.datacollection["datasets"]=[];
for (var thisPath in this.stats.FunctionStatsMap){
var dataSetForPath = {
label: truncate(thisPath,15) + ": "+ this.stats.FunctionStatsMap[thisPath].Queue,
label: thisPath + ": "+ this.stats.FunctionStatsMap[thisPath].Queue,
fill: false, // Only use fill if chart is stacked
backgroundColor: 'white', // needed if fill is false to set fill color in legend
borderColor: getBorderColorFor(thisPath),
Expand All @@ -70,6 +69,26 @@
this.datacollection["datasets"].push(dataSetForPath);

}
var legs = document.getElementById("queuedGraphLegend");

// legend
var text = [];
text.push('<ul class=\'' + 'chartLegend\'>');
var chartDataDatasets = this.datacollection["datasets"];
var chartDataDatasetsLength = chartDataDatasets.length;
for (var i = 0; i < chartDataDatasets.length; i++) {
text.push('<li><span class=\'chartLabelEmblem\' style=\'' +
'background-color:' + chartDataDatasets[i].backgroundColor + '; ' +
'border-color:' + chartDataDatasets[i].borderColor + ';' +
'\'></span>');
if (chartDataDatasets[i].label) {
text.push('<span class=\'chartLabelText\'>'+chartDataDatasets[i].label+'</span>');
}
text.push('</li>');
}
text.push('</ul>');
legs.innerHTML = text.join('');
// end of legend
}
}
},
Expand All @@ -84,4 +103,27 @@
</script>

<style>
.chartLegend{
float:left;
}
.chartLabelEmblem {
float:left;
width:40px;
height:14px;
line-height:20px;
margin-top:3px;
margin-left:10px;
margin-right:6px;
border:1px solid;
font-size:8px;
}
.chartLabelText {
font-size:14px;
}

ul.chartLegend{
margin-right:10px;
list-style-type: none;
padding-left:0px;
}
</style>
Loading