Hi, I've tried to implement your grin example but, it appears to be non-functional. Everything compiles and the graph shows, but the background color is not changed nor does the smiley face show up.
Here's my modified code, nothing else has been changed to my knowledge.
<App.vue-------------------------------------------------------------------------------------->
<script>
import TradingVue from './TradingVue.vue'
import Data from '../data/data.json'
import Utils from './stuff/utils.js'
import Grin from './examples/overlays/Grin.vue'
// New import
export default {
name: 'app',
components: {
TradingVue
},
methods: {
onResize(event) {
this.width = window.innerWidth
this.height = window.innerHeight
}
},
mounted() {
window.addEventListener('resize', this.onResize)
setTimeout(() => {
// Async data setup
this.$set(this, 'chart', Data)
}, 0)
},
beforeDestroy() {
window.removeEventListener('resize', this.onResize)
},
data() {
return {
chart: {}, // Data will be here,
width: window.innerWidth,
height: window.innerHeight,
colors: {
colorBack: '#fff',
colorGrid: '#eee',
colorText: '#333',
},
overlays: [Grin]
};
}
};
</script>
<style>
html,
body {
background-color: #000;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
<Grin.vue------------------------------------------------------------------------------------------------------------------------->
<script>
// Grin
// Adds all necessary stuff for you.
import Overlay from '../../mixins/overlay.js'
export default {
name: 'Grin',
mixins: [Overlay],
methods: {
meta_info() {
return { author: 'C451', version: '1.0.0' }
},
// Here goes your code. You are provided with:
// { All stuff is reactive }
// $props.layout -> positions of all chart elements +
// some helper functions (see layout_fn.js)
// $props.interval -> candlestick time interval
// $props.sub -> current subset of candlestick data
// $props.data -> your indicator's data subset.
// Comes "as is", should have the following format:
// [[, ... ], ... ]
// $props.colors -> colors (see TradingVue.vue)
// $props.cursor -> current position of crosshair
// $props.settings -> indicator custom settings
// E.g. colors, line thickness, etc. You define it.
// ~
// Finally, let's make the canvas dirty!
draw(ctx) {
const l = this.$props.layout
const c = { x : l.width / 2, y : l.height / 2 }
ctx.lineWidth = 1
ctx.strokeStyle = 'gray'
ctx.fillStyle = '#ffea03'
ctx.beginPath()
ctx.arc(c.x, c.y, 50, 0, Math.PI * 2, true) // Outer circle
ctx.fill()
ctx.stroke()
ctx.beginPath()
ctx.strokeStyle = 'black'
ctx.moveTo(c.x + 35, c.y)
ctx.arc(c.x, c.y, 35, 0, Math.PI , false) // Mouth (clockwise)
ctx.moveTo(c.x - 10, c.y - 10)
ctx.fillStyle = '#ffea03'
ctx.arc(c.x - 15, c.y - 10, 5, 0, Math.PI * 2, true) // Left eye
ctx.fill()
ctx.moveTo(c.x + 20, c.y - 10)
ctx.arc(c.x + 15, c.y - 10, 5, 0, Math.PI * 2, true) // Right eye
ctx.fill()
ctx.stroke()
},
// For all data with these types overlay will be
// added to the renderer list. And '$props.data'
// will have the corresponding values. If you want to
// redefine the default behviour for a prticular
// indicator (let's say EMA),
// just create a new overlay with the same type:
// e.g. use_for() { return ['EMA'] }.
use_for() { return ['GRIN'] },
data_colors() { return ['yellow'] }
},
data() {
// Define internal setting & constants here
return {}
}
}
</script>
Ubuntu 18.04
Visual Studio Code
Compiled with npm
Run in bash with "npm run dev"
robot_enthusiast@TradingBotMaster:~/git/Vue$ npm run dev
[email protected] dev /home/robot_enthusiast/git/Vue
webpack-dev-server --config webpack/dev.config.js --mode development --progress --hot
10% building 1/1 modules 0 activeโน ๏ฝขwds๏ฝฃ: Project is running at http://localhost:8080/
โน ๏ฝขwds๏ฝฃ: webpack output is served from /
โน ๏ฝขwdm๏ฝฃ: Hash: 37f5e7b4c1dc92ceb56e
Version: webpack 4.30.0
Time: 4073ms
Built at: 04/20/2019 8:00:42 PM
Asset Size Chunks Chunk Names
index.html 475 bytes [emitted]
main.js 1.59 MiB main [emitted] main
Entrypoint main = main.js
[0] multi (webpack)-dev-server/client?http://localhost (webpack)/hot/dev-server.js ./src/main.js 52 bytes {main} [built]
[./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built]
[./node_modules/querystring-es3/index.js] 127 bytes {main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/url/url.js] 22.8 KiB {main} [built]
[./node_modules/vue/dist/vue.runtime.esm.js] 222 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost] (webpack)-dev-server/client?http://localhost 8.26 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built]
[./node_modules/webpack/hot sync ^./log$] (webpack)/hot sync nonrecursive ^./log$ 170 bytes {main} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.61 KiB {main} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built]
[./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.27 KiB {main} [built]
[./node_modules/webpack/hot/log.js] (webpack)/hot/log.js 1.11 KiB {main} [built]
[./src/main.js] 133 bytes {main} [built]
+ 103 hidden modules
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html] 634 bytes {0} [built]
[./node_modules/lodash/lodash.js] 527 KiB {0} [built]
[./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 472 bytes {0} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {0} [built]
โน ๏ฝขwdm๏ฝฃ: Compiled successfully.