Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datacube format #255

Open
denisprovost opened this issue Nov 12, 2021 · 1 comment
Open

Datacube format #255

denisprovost opened this issue Nov 12, 2021 · 1 comment

Comments

@denisprovost
Copy link

denisprovost commented Nov 12, 2021

Hi,

I request data from my API to display them on the graph, the debug shows that I am getting my data well but nothing on the graph:

1

My actual test code:

<template>
    <span>
        <trading-vue 
            ref="tvjs"
            title-txt="ETHUSDT Binance 1h"
            :data="chart" 
            :width="width"
            :height="height" 
            :overlays="overlays">
        </trading-vue>
    </span>
</template>

<script>
import TradingVue from 'trading-vue-js'
import { DataCube } from 'trading-vue-js'

const SM = `http://localhost:7000/binder`

export default {
    name: 'app',
    components: { TradingVue },
  	computed: {},
    mounted() { 
        window.addEventListener('resize', this.onResize)
        this.onResize()

        this.load_bind().then(data => {
            this.chart = new DataCube({
                ohlcv: data['chart.data'],
                onchart: [],
                offchart: [],
                datasets: []
            }, { aggregation: 100 })

            this.chart.onrange(this.load_bind)
            this.$refs.tvjs.resetChart()
        })
    },
    methods: {
        onResize(event) {
            this.width = window.innerWidth
            this.height = window.innerHeight
        },

        async load_bind() {
            try {
                let r = await fetch(SM).then(r => r.json())
                console.log('datas RealManager')
                console.log({'chart.data': this.parse_datas(r)})
                return {'chart.data': this.parse_datas(r)}
            } catch (error) {
                console.log(error);
            }
        },
        parse_datas(data) {
            if (!Array.isArray(data)) return []
            return data.map(x => {
                for (var i = 0; i < x.length; i++) {
                    x[i] = parseFloat(x[i])
                }
                return x.slice(0,6)
            })
        }
    },
    beforeDestroy() { 
        window.removeEventListener('resize', this.onResize)
    },
    data() {
        return {
            chart: {},
            overlays: [],
        }
    }
}
</script>

My setup is correct, i have test with the DataHelper example, it work correctly :)
Anyone have an idea to debug this ? I forgot something ?

Thanks.

@Bwahharharrr
Copy link

trading-vue works absolutely fine.
This is a problem with your code, not with trading-vue. . thus not a trading-vue issue .. its a 'your code' issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants