mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-21 23:53:52 +00:00
fix: Re-map fill_to values, too
This commit is contained in:
parent
a43a5924c7
commit
8cb21af220
|
@ -50,6 +50,10 @@ function replaceTemplateColumns(template: Partial<PlotConfig>, nameMap: Record<s
|
|||
for (const key in template.main_plot) {
|
||||
const newKey = nameMap[key] || key;
|
||||
newMainPlot[newKey] = template.main_plot[key];
|
||||
if (newMainPlot[newKey].fill_to !== undefined) {
|
||||
newMainPlot[newKey].fill_to =
|
||||
nameMap[newMainPlot[newKey].fill_to] || newMainPlot[newKey].fill_to;
|
||||
}
|
||||
}
|
||||
if ('main_plot' in template) {
|
||||
newTemplate.main_plot = newMainPlot;
|
||||
|
@ -62,6 +66,10 @@ function replaceTemplateColumns(template: Partial<PlotConfig>, nameMap: Record<s
|
|||
for (const key in template.subplots[subplotKey]) {
|
||||
const newKey = nameMap[key] || key;
|
||||
newSubplot[newKey] = template.subplots[subplotKey][key];
|
||||
if (newSubplot[newKey].fill_to !== undefined) {
|
||||
newSubplot[newKey].fill_to =
|
||||
nameMap[newSubplot[newKey].fill_to] || newSubplot[newKey].fill_to;
|
||||
}
|
||||
}
|
||||
newSubplots[subplotKey] = newSubplot;
|
||||
}
|
||||
|
|
|
@ -95,4 +95,66 @@ describe('plotTemplates.ts', () => {
|
|||
};
|
||||
expect(replaceTemplateColumns(template, reMapping)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('Updates "fill to" values', () => {
|
||||
const { replaceTemplateColumns } = usePlotTemplates();
|
||||
const reMapping = {
|
||||
bb_upperband: 'upperband',
|
||||
bb_lowerband: 'lowerband',
|
||||
macd: 'macd_5m',
|
||||
};
|
||||
const template: Partial<PlotConfig> = {
|
||||
main_plot: {
|
||||
bb_upperband: {
|
||||
color: '#008af4',
|
||||
type: 'line',
|
||||
fill_to: 'bb_lowerband',
|
||||
},
|
||||
bb_lowerband: {
|
||||
color: '#008af4',
|
||||
type: 'line',
|
||||
},
|
||||
},
|
||||
subplots: {
|
||||
MACD: {
|
||||
macdsignal: {
|
||||
color: '#ff8000',
|
||||
type: 'line',
|
||||
fill_to: 'macd',
|
||||
},
|
||||
macd: {
|
||||
color: '#1370f4',
|
||||
type: 'line',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const expected: Partial<PlotConfig> = {
|
||||
main_plot: {
|
||||
upperband: {
|
||||
color: '#008af4',
|
||||
type: 'line',
|
||||
fill_to: 'lowerband',
|
||||
},
|
||||
lowerband: {
|
||||
color: '#008af4',
|
||||
type: 'line',
|
||||
},
|
||||
},
|
||||
subplots: {
|
||||
MACD: {
|
||||
macdsignal: {
|
||||
color: '#ff8000',
|
||||
type: 'line',
|
||||
fill_to: 'macd_5m',
|
||||
},
|
||||
macd_5m: {
|
||||
color: '#1370f4',
|
||||
type: 'line',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(replaceTemplateColumns(template, reMapping)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user