mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 21:15:15 +00:00
Extract function to separate file
This commit is contained in:
parent
b9d2b90bd6
commit
1fb43f5c5b
|
@ -6,15 +6,15 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import { Trade, PairHistory, PlotConfig, ChartSliderPosition, IndicatorConfig } from '@/types';
|
||||
import randomColor from '@/shared/randomColor';
|
||||
import { Trade, PairHistory, PlotConfig, ChartSliderPosition } from '@/types';
|
||||
import { generateCandleSeries } from '@/shared/charts/candleChartSeries';
|
||||
import heikinashi from '@/shared/charts/heikinashi';
|
||||
import { getTradeEntries } from '@/shared/charts/tradeChartData';
|
||||
import ECharts from 'vue-echarts';
|
||||
import { format } from 'date-fns-tz';
|
||||
|
||||
import { use } from 'echarts/core';
|
||||
import { EChartsOption, SeriesOption, ScatterSeriesOption } from 'echarts';
|
||||
import { EChartsOption, ScatterSeriesOption } from 'echarts';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
import { CandlestickChart, LineChart, BarChart, ScatterChart } from 'echarts/charts';
|
||||
import {
|
||||
|
@ -111,30 +111,6 @@ const chartTitle = computed(() => {
|
|||
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) {
|
||||
if (!hasData.value) {
|
||||
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