From 2b63358223d995f309c99019f79f6e4759c36dde Mon Sep 17 00:00:00 2001 From: icebox Date: Mon, 21 May 2018 19:22:20 +0200 Subject: [PATCH] fix(quotes): fix sparklines Remove render and update dead methods in sl and ohlc charts. --- build/app.bundle.js | 90 ++++++++----------- .../ohlc-chart/ohlc-chart.element.js | 6 -- .../ohlc-chart/ohlc-chart.template.js | 7 -- .../app/components/quotes/quotes.template.js | 4 +- .../components/sl-chart/sl-chart.element.js | 6 -- .../components/sl-chart/sl-chart.template.js | 7 -- 6 files changed, 39 insertions(+), 81 deletions(-) diff --git a/build/app.bundle.js b/build/app.bundle.js index 24ddc203..5f69f4b5 100644 --- a/build/app.bundle.js +++ b/build/app.bundle.js @@ -1,7 +1,7 @@ (function (hyperHTML,Introspected,d3,techan) { 'use strict'; - var hyperHTML__default = 'default' in hyperHTML ? hyperHTML['default'] : hyperHTML; + hyperHTML = hyperHTML && hyperHTML.hasOwnProperty('default') ? hyperHTML['default'] : hyperHTML; Introspected = Introspected && Introspected.hasOwnProperty('default') ? Introspected['default'] : Introspected; techan = techan && techan.hasOwnProperty('default') ? techan['default'] : techan; @@ -99,7 +99,7 @@ class RootComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("root")); + const render = hyperHTML.bind(Util.query("root")); RootTemplate.update(render); } @@ -188,7 +188,7 @@ class AppComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("app")); + const render = hyperHTML.bind(Util.query("app")); this.appController = new AppController(render, AppTemplate); } @@ -413,7 +413,7 @@ class AccountComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("account")); + const render = hyperHTML.bind(Util.query("account")); this.accountController = new AccountController(render, AccountTemplate); } @@ -452,7 +452,7 @@ const highlight = classes + (activity.pl >= 0 ? " highlight-green" : " highlight-red"); - return hyperHTML__default.wire(activity, ":tr")` + return hyperHTML.wire(activity, ":tr")` ${activity.id} ${activity.type} ${activity.instrument} @@ -544,7 +544,7 @@ class ActivityComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("activity")); + const render = hyperHTML.bind(Util.query("activity")); this.activityController = new ActivityController(render, ActivityTemplate); } @@ -573,7 +573,7 @@ } }}">${ - state.account.streamingInstruments.map(instrument => hyperHTML__default.wire()` + state.account.streamingInstruments.map(instrument => hyperHTML.wire()` @@ -590,7 +590,7 @@ } }}">${ - state.granularities.map(granularity => hyperHTML__default.wire()` + state.granularities.map(granularity => hyperHTML.wire()` @@ -758,7 +758,7 @@ ${ - state.orderInfo.expires.map(expiry => hyperHTML__default.wire()` + state.orderInfo.expires.map(expiry => hyperHTML.wire()` @@ -1255,7 +1255,7 @@ class OrderDialogComponent { static bootstrap(state) { - const render = hyperHTML__default.bind(Util.query("order-dialog")); + const render = hyperHTML.bind(Util.query("order-dialog")); this.orderDialogController = new OrderDialogController(render, OrderDialogTemplate, state); } @@ -1531,7 +1531,7 @@ class ChartsComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("charts")); + const render = hyperHTML.bind(Util.query("charts")); this.chartsController = new ChartsController(render, ChartsTemplate); } @@ -1560,7 +1560,7 @@ state.exposure.map(exposure => { const classes = "pv1 pr1 bb b--black-20 tr"; - return hyperHTML__default.wire(exposure, ":tr")` + return hyperHTML.wire(exposure, ":tr")` ${exposure.type} ${exposure.market} ${Util.formatNumber(exposure.units)} @@ -1586,7 +1586,7 @@ class ExposureComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("exposure")); + const render = hyperHTML.bind(Util.query("exposure")); this.exposureController = new ExposureController(render, ExposureTemplate); } @@ -1669,7 +1669,7 @@ Object.keys(state.instrs).map(instrument => { const value = !!state.instrs[instrument]; - return hyperHTML__default.wire()` + return hyperHTML.wire()`
${ - state.accounts.map((account, index) => hyperHTML__default.wire(account, ":li")` + state.accounts.map((account, index) => hyperHTML.wire(account, ":li")` { const classes = "pv1 pr1 bb b--black-20 tr"; - return hyperHTML__default.wire(news, ":tr")` + return hyperHTML.wire(news, ":tr")` ${Util.formatDate(news.timestamp)} ${news.currency} ${news.title} @@ -2281,7 +2281,7 @@ class NewsComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("news")); + const render = hyperHTML.bind(Util.query("news")); this.newsController = new NewsController(render, NewsTemplate); } @@ -2291,12 +2291,6 @@ class OhlcChartTemplate { - static update(render) { - return render`${hyperHTML__default.wire(render, "svg")` - ` - }`; - } - static redrawData(state) { if (!state.data) { return; @@ -2672,10 +2666,6 @@ }; } - static render() { - return OhlcChartTemplate.update(hyperHTML.wire()); - } - attributeChangedCallback(name) { OhlcChartElement.state.instrument = this.dataset.instrument; OhlcChartElement.state.granularity = this.dataset.granularity; @@ -2735,7 +2725,7 @@ state.orders.map(order => { const classes = "pv1 pr1 bb b--black-20 tr"; - return hyperHTML__default.wire(order, ":tr")` + return hyperHTML.wire(order, ":tr")` ${order.side || order.type} { const value = !!state.plugins[plugin]; - return hyperHTML__default.wire()` + return hyperHTML.wire()` { const classes = "pv1 pr1 bb b--black-20 tr"; - return hyperHTML__default.wire(position, ":tr")` + return hyperHTML.wire(position, ":tr")` ${position.side} ${position.instrument} ${Util.formatNumber(position.units)} @@ -2991,7 +2981,7 @@ class PositionsComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("positions")); + const render = hyperHTML.bind(Util.query("positions")); this.positionsController = new PositionsController(render, PositionsTemplate); } @@ -3015,10 +3005,12 @@ Object.keys(state.quotes).map(instrument => { const quote = state.quotes[instrument]; - return hyperHTML__default.wire(quote, ":tr")` + return hyperHTML.wire(quote, ":tr")` ${instrument} - + + + ${quote.bid} ${quote.ask} @@ -3089,7 +3081,7 @@ class QuotesComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("quotes")); + const render = hyperHTML.bind(Util.query("quotes")); this.quotesController = new QuotesController(render, QuotesTemplate); } @@ -3099,12 +3091,6 @@ class SlChartTemplate { - static update(render) { - return render`${hyperHTML__default.wire(render, "svg")` - ` - }`; - } - // Inspired by http://bl.ocks.org/vicapow/9904319 static redraw(state) { const instrument = state.instrument, @@ -3181,10 +3167,6 @@ }; } - static render() { - return SlChartTemplate.update(hyperHTML.wire()); - } - /* eslint class-methods-use-this: "off" */ attributeChangedCallback(attr, oldValue, newValue) { SlChartElement.state.instrument = JSON.parse(newValue).instrument; @@ -3231,7 +3213,7 @@ class ToastsComponent { static bootstrap() { - const render = hyperHTML__default.bind(Util.query("toasts")); + const render = hyperHTML.bind(Util.query("toasts")); this.toastsController = new ToastsController(render, ToastsTemplate); } @@ -3271,7 +3253,7 @@ const highlight = classes + (trade.profitPips >= 0 ? " highlight-green" : " highlight-red"); - return hyperHTML__default.wire(trade, ":tr")` + return hyperHTML.wire(trade, ":tr")` ${trade.side} ` - }`; - } - static redrawData(state) { if (!state.data) { return; diff --git a/src/client/app/components/quotes/quotes.template.js b/src/client/app/components/quotes/quotes.template.js index 2919ac01..91439328 100644 --- a/src/client/app/components/quotes/quotes.template.js +++ b/src/client/app/components/quotes/quotes.template.js @@ -21,7 +21,9 @@ export class QuotesTemplate { return hyperHTML.wire(quote, ":tr")` ${instrument} - + + + ${quote.bid} ${quote.ask} diff --git a/src/client/app/components/sl-chart/sl-chart.element.js b/src/client/app/components/sl-chart/sl-chart.element.js index 414db03c..a4f6290c 100644 --- a/src/client/app/components/sl-chart/sl-chart.element.js +++ b/src/client/app/components/sl-chart/sl-chart.element.js @@ -1,5 +1,3 @@ -import { wire } from "hyperHTML"; - import { QuotesService } from "../quotes/quotes.service.js"; import { SlChartTemplate } from "./sl-chart.template.js"; @@ -18,10 +16,6 @@ class SlChartElement extends HTMLElement { }; } - static render() { - return SlChartTemplate.update(wire()); - } - /* eslint class-methods-use-this: "off" */ attributeChangedCallback(attr, oldValue, newValue) { SlChartElement.state.instrument = JSON.parse(newValue).instrument; diff --git a/src/client/app/components/sl-chart/sl-chart.template.js b/src/client/app/components/sl-chart/sl-chart.template.js index 3b088fbf..ad97d48e 100644 --- a/src/client/app/components/sl-chart/sl-chart.template.js +++ b/src/client/app/components/sl-chart/sl-chart.template.js @@ -1,14 +1,7 @@ import * as d3 from "d3"; -import hyperHTML from "hyperHTML"; export class SlChartTemplate { - static update(render) { - return render`${hyperHTML.wire(render, "svg")` - ` - }`; - } - // Inspired by http://bl.ocks.org/vicapow/9904319 static redraw(state) { const instrument = state.instrument,