Skip to content

Commit

Permalink
👌 IMPROVE: allow configuration of legend alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Sep 10, 2020
1 parent 97fdf53 commit d39e90c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/assets/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var longestCommonPrefix = function(strs) {
}


export function renderGraph(canvas, dataset, labels, xAxis, alpha = 60, fill = true, labelString = 'iter/sec') {
export function renderGraph(canvas, dataset, labels, xAxis, alpha = 60, fill = true, legendAlign = 'center', labelString = 'iter/sec') {

const colorCycle = cycle(['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']);

Expand Down Expand Up @@ -111,7 +111,7 @@ export function renderGraph(canvas, dataset, labels, xAxis, alpha = 60, fill = t
},
legend: {
position: 'top',
align: 'center',
align: legendAlign,
// TODO legend titles only available in chartjs v3
// rather then chart title
// title: {text: 'hallo', display: true},
Expand Down
3 changes: 2 additions & 1 deletion src/assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function renderBenchSetGroups(domElement, name, benchSets, configEntry, configGr
});
const labels = uniqueCommits.map((d) => (configGroup.xAxis === 'date') ? moment(d[0]) : d[1].slice(0, 7));
const fill = configGroup.backgroundFill === undefined ? true : configGroup.backgroundFill
renderGraph(canvas, datasets, labels, configGroup.xAxis, 10, fill)
const legendAlign = configGroup.legendAlign === undefined ? 'center' : configGroup.legendAlign
renderGraph(canvas, datasets, labels, configGroup.xAxis, 10, fill, legendAlign)
} else {
for (const [benchName, benches] of benchSet.entries()) {
const canvas = document.createElement('canvas');
Expand Down

0 comments on commit d39e90c

Please sign in to comment.