mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-11 02:33:51 +00:00
Extract function to separate file
This commit is contained in:
parent
b9d2b90bd6
commit
1fb43f5c5b
|
@ -6,15 +6,15 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, watch } from 'vue';
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import { Trade, PairHistory, PlotConfig, ChartSliderPosition, IndicatorConfig } from '@/types';
|
import { Trade, PairHistory, PlotConfig, ChartSliderPosition } from '@/types';
|
||||||
import randomColor from '@/shared/randomColor';
|
import { generateCandleSeries } from '@/shared/charts/candleChartSeries';
|
||||||
import heikinashi from '@/shared/charts/heikinashi';
|
import heikinashi from '@/shared/charts/heikinashi';
|
||||||
import { getTradeEntries } from '@/shared/charts/tradeChartData';
|
import { getTradeEntries } from '@/shared/charts/tradeChartData';
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
import { format } from 'date-fns-tz';
|
import { format } from 'date-fns-tz';
|
||||||
|
|
||||||
import { use } from 'echarts/core';
|
import { use } from 'echarts/core';
|
||||||
import { EChartsOption, SeriesOption, ScatterSeriesOption } from 'echarts';
|
import { EChartsOption, ScatterSeriesOption } from 'echarts';
|
||||||
import { CanvasRenderer } from 'echarts/renderers';
|
import { CanvasRenderer } from 'echarts/renderers';
|
||||||
import { CandlestickChart, LineChart, BarChart, ScatterChart } from 'echarts/charts';
|
import { CandlestickChart, LineChart, BarChart, ScatterChart } from 'echarts/charts';
|
||||||
import {
|
import {
|
||||||
|
@ -111,30 +111,6 @@ const chartTitle = computed(() => {
|
||||||
return `${strategy.value} - ${pair.value} - ${timeframe.value}`;
|
return `${strategy.value} - ${pair.value} - ${timeframe.value}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
function generateCandleSeries(
|
|
||||||
colDate: number,
|
|
||||||
col: number,
|
|
||||||
key: string,
|
|
||||||
value: IndicatorConfig,
|
|
||||||
axis = 0,
|
|
||||||
): SeriesOption {
|
|
||||||
const sp: SeriesOption = {
|
|
||||||
name: key,
|
|
||||||
type: value.type || 'line',
|
|
||||||
xAxisIndex: axis,
|
|
||||||
yAxisIndex: axis,
|
|
||||||
itemStyle: {
|
|
||||||
color: value.color || randomColor(),
|
|
||||||
},
|
|
||||||
encode: {
|
|
||||||
x: colDate,
|
|
||||||
y: col,
|
|
||||||
},
|
|
||||||
showSymbol: false,
|
|
||||||
};
|
|
||||||
return sp;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateChart(initial = false) {
|
function updateChart(initial = false) {
|
||||||
if (!hasData.value) {
|
if (!hasData.value) {
|
||||||
return;
|
return;
|
||||||
|
|
27
src/shared/charts/candleChartSeries.ts
Normal file
27
src/shared/charts/candleChartSeries.ts
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import { IndicatorConfig } from '@/types';
|
||||||
|
import { SeriesOption } from 'echarts';
|
||||||
|
import randomColor from '../randomColor';
|
||||||
|
|
||||||
|
export function generateCandleSeries(
|
||||||
|
colDate: number,
|
||||||
|
col: number,
|
||||||
|
key: string,
|
||||||
|
value: IndicatorConfig,
|
||||||
|
axis = 0,
|
||||||
|
): SeriesOption {
|
||||||
|
const sp: SeriesOption = {
|
||||||
|
name: key,
|
||||||
|
type: value.type || 'line',
|
||||||
|
xAxisIndex: axis,
|
||||||
|
yAxisIndex: axis,
|
||||||
|
itemStyle: {
|
||||||
|
color: value.color || randomColor(),
|
||||||
|
},
|
||||||
|
encode: {
|
||||||
|
x: colDate,
|
||||||
|
y: col,
|
||||||
|
},
|
||||||
|
showSymbol: false,
|
||||||
|
};
|
||||||
|
return sp;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user