mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
feat: Dynamically generate legend labels based on unique edit formats
This commit is contained in:
parent
45474a230e
commit
752e823da8
1 changed files with 31 additions and 31 deletions
|
@ -116,46 +116,46 @@
|
||||||
position: 'top',
|
position: 'top',
|
||||||
labels: {
|
labels: {
|
||||||
generateLabels: function(chart) {
|
generateLabels: function(chart) {
|
||||||
return [
|
var uniqueFormats = [...new Set(allData.map(item => item.edit_format))];
|
||||||
{
|
return uniqueFormats.map(format => {
|
||||||
text: 'whole',
|
var color;
|
||||||
fillStyle: 'rgba(255, 99, 132, 0.2)',
|
switch (format) {
|
||||||
strokeStyle: 'rgba(255, 99, 132, 1)',
|
case 'whole':
|
||||||
lineWidth: 1,
|
color = { fill: 'rgba(255, 99, 132, 0.2)', stroke: 'rgba(255, 99, 132, 1)' };
|
||||||
hidden: false
|
break;
|
||||||
},
|
case 'diff':
|
||||||
{
|
color = { fill: 'rgba(54, 162, 235, 0.2)', stroke: 'rgba(54, 162, 235, 1)' };
|
||||||
text: 'diff',
|
break;
|
||||||
fillStyle: 'rgba(54, 162, 235, 0.2)',
|
case 'udiff':
|
||||||
strokeStyle: 'rgba(54, 162, 235, 1)',
|
color = { fill: 'rgba(75, 192, 192, 0.2)', stroke: 'rgba(75, 192, 192, 1)' };
|
||||||
lineWidth: 1,
|
break;
|
||||||
hidden: false
|
case 'diff-fenced':
|
||||||
},
|
color = { fill: 'rgba(153, 102, 255, 0.2)', stroke: 'rgba(153, 102, 255, 1)' };
|
||||||
{
|
break;
|
||||||
text: 'udiff',
|
default:
|
||||||
fillStyle: 'rgba(75, 192, 192, 0.2)',
|
color = { fill: 'rgba(201, 203, 207, 0.2)', stroke: 'rgba(201, 203, 207, 1)' };
|
||||||
strokeStyle: 'rgba(75, 192, 192, 1)',
|
|
||||||
lineWidth: 1,
|
|
||||||
hidden: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'diff-fenced',
|
|
||||||
fillStyle: 'rgba(153, 102, 255, 0.2)',
|
|
||||||
strokeStyle: 'rgba(153, 102, 255, 1)',
|
|
||||||
lineWidth: 1,
|
|
||||||
hidden: false
|
|
||||||
}
|
}
|
||||||
];
|
return {
|
||||||
|
text: format,
|
||||||
|
fillStyle: color.fill,
|
||||||
|
strokeStyle: color.stroke,
|
||||||
|
lineWidth: 1,
|
||||||
|
hidden: false
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick: function(e, legendItem, legend) {
|
onClick: function(e, legendItem, legend) {
|
||||||
var index = legendItem.index;
|
|
||||||
var ci = legend.chart;
|
var ci = legend.chart;
|
||||||
var clickedFormat = legendItem.text;
|
var clickedFormat = legendItem.text;
|
||||||
|
|
||||||
|
legendItem.hidden = !legendItem.hidden;
|
||||||
|
|
||||||
ci.data.datasets[0].data.forEach(function(dataPoint, i) {
|
ci.data.datasets[0].data.forEach(function(dataPoint, i) {
|
||||||
var meta = ci.getDatasetMeta(0);
|
var meta = ci.getDatasetMeta(0);
|
||||||
meta.data[i].hidden = allData[i].edit_format !== clickedFormat;
|
if (allData[i].edit_format === clickedFormat) {
|
||||||
|
meta.data[i].hidden = legendItem.hidden;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ci.update();
|
ci.update();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue