Fix colors in daily / hourly charts

This commit is contained in:
Matthias 2020-08-18 20:51:16 +02:00
parent c0c2cb8d74
commit 09de9726f9
2 changed files with 31 additions and 16 deletions

View File

@ -26,6 +26,24 @@ const CHART_TRADE_COUNT = 'Trade Count';
export default class DailyChart extends Vue { export default class DailyChart extends Vue {
@Prop({ required: true }) dailyStats!: DailyReturnValue; @Prop({ required: true }) dailyStats!: DailyReturnValue;
get absoluteMin() {
return Number(
this.dailyStats.data.reduce(
(min, p) => (p.abs_profit < min ? p.abs_profit : min),
this.dailyStats.data[0].abs_profit,
),
);
}
get absoluteMax() {
return Number(
this.dailyStats.data.reduce(
(max, p) => (p.abs_profit > max ? p.abs_profit : max),
this.dailyStats.data[0].abs_profit,
),
);
}
get dailyChartOptions() { get dailyChartOptions() {
return { return {
title: { title: {
@ -58,18 +76,14 @@ export default class DailyChart extends Vue {
show: false, show: false,
pieces: [ pieces: [
{ {
min: 0.0, max: -0.01,
color: 'green', min: this.absoluteMin - 2,
},
{
value: 0.0,
color: 'gray',
},
{
max: 0.0,
min: -100000,
color: 'red', color: 'red',
}, },
{
min: -0.00001,
color: 'green',
},
], ],
}, },
yAxis: [ yAxis: [

View File

@ -19,7 +19,7 @@ import { Trade } from '@/store/types';
import { timestampHour } from '@/shared/formatters'; import { timestampHour } from '@/shared/formatters';
// Define Column labels here to avoid typos // Define Column labels here to avoid typos
const CHART_PROFIT = 'Profit'; const CHART_PROFIT = 'Profit %';
const CHART_TRADE_COUNT = 'Trade Count'; const CHART_TRADE_COUNT = 'Trade Count';
@Component({ @Component({
@ -98,13 +98,14 @@ export default class HourlyChart extends Vue {
show: false, show: false,
pieces: [ pieces: [
{ {
min: 0, max: -0.001,
color: 'green', // min: -2,
color: 'red',
}, },
{ {
max: 0.0, min: -0.01,
min: -1, max: 2,
color: 'red', color: 'green',
}, },
], ],
}, },