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 {
@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() {
return {
title: {
@ -58,18 +76,14 @@ export default class DailyChart extends Vue {
show: false,
pieces: [
{
min: 0.0,
color: 'green',
},
{
value: 0.0,
color: 'gray',
},
{
max: 0.0,
min: -100000,
max: -0.01,
min: this.absoluteMin - 2,
color: 'red',
},
{
min: -0.00001,
color: 'green',
},
],
},
yAxis: [

View File

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