Compare commits
No commits in common. "14b80dfea6bc93333f3d4e072e206017772de5de" and "df7e5c0e97886450a0868a829aa76c7a8da17856" have entirely different histories.
14b80dfea6
...
df7e5c0e97
17
src/index.js
17
src/index.js
@ -6,7 +6,7 @@ import fetchData from "./fetchData";
|
|||||||
import {updateHighTime} from "./highTime";
|
import {updateHighTime} from "./highTime";
|
||||||
import {updateLowTime} from "./lowTime";
|
import {updateLowTime} from "./lowTime";
|
||||||
import {addLoader, removeLoader} from "./loader";
|
import {addLoader, removeLoader} from "./loader";
|
||||||
import {allowOverlay, forceOverlayOff, forceOverlayOn, isOverlayAllowed, isOverlaySelected} from "./overlay";
|
import {allowOverlay, forceOverlayOff, isOverlaySelected} from "./overlay";
|
||||||
import TokenChart from "./tokenChart";
|
import TokenChart from "./tokenChart";
|
||||||
import Datum from "./datum";
|
import Datum from "./datum";
|
||||||
|
|
||||||
@ -212,15 +212,6 @@ function detectZeroQuery(urlSearchParams) {
|
|||||||
toggleStartYAtZero();
|
toggleStartYAtZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectOverlayQuery(urlSearchParams) {
|
|
||||||
const enableOverlay = urlSearchParams.get('overlay') === 'previous_time';
|
|
||||||
if (enableOverlay) {
|
|
||||||
forceOverlayOn();
|
|
||||||
} else {
|
|
||||||
forceOverlayOff();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function detectURLQuery() {
|
function detectURLQuery() {
|
||||||
const urlSearchParams = new URLSearchParams(window.location.search);
|
const urlSearchParams = new URLSearchParams(window.location.search);
|
||||||
if (urlSearchParams.has('region')) {
|
if (urlSearchParams.has('region')) {
|
||||||
@ -235,9 +226,6 @@ function detectURLQuery() {
|
|||||||
if (urlSearchParams.has('startAtZero')) {
|
if (urlSearchParams.has('startAtZero')) {
|
||||||
detectZeroQuery(urlSearchParams)
|
detectZeroQuery(urlSearchParams)
|
||||||
}
|
}
|
||||||
if (urlSearchParams.has('overlay')) {
|
|
||||||
detectOverlayQuery(urlSearchParams);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDeepLinksURL() {
|
function buildDeepLinksURL() {
|
||||||
@ -254,9 +242,6 @@ function buildDeepLinksURL() {
|
|||||||
if (startYAtZero !== false){
|
if (startYAtZero !== false){
|
||||||
url += `startAtZero=${startYAtZero}&`
|
url += `startAtZero=${startYAtZero}&`
|
||||||
}
|
}
|
||||||
if (isOverlaySelected()){
|
|
||||||
url += `overlay=previous_time&`
|
|
||||||
}
|
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,22 +19,9 @@ function forceOverlayOff(){
|
|||||||
periodOverlayField.style.display = 'none';
|
periodOverlayField.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
function forceOverlayOn(){
|
|
||||||
const overlaySetting = document.getElementById("period-overlay");
|
|
||||||
const periodOverlayField = document.getElementById("period-overlay-options");
|
|
||||||
const advancedOptionsField = document.getElementById("advanced-options");
|
|
||||||
overlaySetting.checked = true;
|
|
||||||
advancedOptionsField.style.display = 'flex';
|
|
||||||
periodOverlayField.style.display = 'flex';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isOverlayAllowed(timeSelection) {
|
|
||||||
return !(timeSelection === "all")
|
|
||||||
}
|
|
||||||
|
|
||||||
function allowOverlay(){
|
function allowOverlay(){
|
||||||
const periodOverlayField = document.getElementById("period-overlay-options");
|
const periodOverlayField = document.getElementById("period-overlay-options");
|
||||||
periodOverlayField.style.display = 'flex';
|
periodOverlayField.style.display = 'flex';
|
||||||
}
|
}
|
||||||
|
|
||||||
export {isOverlaySelected, getOverlayTime, setOverlayLabelTime, forceOverlayOff, forceOverlayOn, isOverlayAllowed, allowOverlay};
|
export {isOverlaySelected, getOverlayTime, setOverlayLabelTime, forceOverlayOff, allowOverlay};
|
@ -25,7 +25,6 @@ Chart.register(
|
|||||||
import {updateHighVal} from "./highTime";
|
import {updateHighVal} from "./highTime";
|
||||||
import {updateLowVal} from "./lowTime";
|
import {updateLowVal} from "./lowTime";
|
||||||
import {isOverlaySelected, getOverlayTime, setOverlayLabelTime} from "./overlay";
|
import {isOverlaySelected, getOverlayTime, setOverlayLabelTime} from "./overlay";
|
||||||
import Datum from "./datum";
|
|
||||||
|
|
||||||
function lookupTimeUnit(query){
|
function lookupTimeUnit(query){
|
||||||
const lookup = {
|
const lookup = {
|
||||||
@ -78,22 +77,6 @@ export default class TokenChart {
|
|||||||
this._chart = new Chart(this._context, chartConfig);
|
this._chart = new Chart(this._context, chartConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #updateHighLow(datum) {
|
|
||||||
if (this._highDatum === null) {
|
|
||||||
this._highDatum = new Datum(datum.getTime(), 0);
|
|
||||||
this._lowDatum = datum;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (datum.getPrice() > this._highDatum.getPrice()) {
|
|
||||||
this._highDatum = datum;
|
|
||||||
updateHighVal(this.highDatum);
|
|
||||||
}
|
|
||||||
else if (datum.getPrice() < this._lowDatum.getPrice()) {
|
|
||||||
this._lowDatum = datum;
|
|
||||||
updateLowVal(this.lowDatum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async #createOverlayChart(region, time, yLevel, data){
|
async #createOverlayChart(region, time, yLevel, data){
|
||||||
const chartData = [];
|
const chartData = [];
|
||||||
const overlayData = [];
|
const overlayData = [];
|
||||||
@ -108,7 +91,15 @@ export default class TokenChart {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await this.#updateHighLow(data[i]);
|
|
||||||
|
this._lastDatum = data[i];
|
||||||
|
if (this._highDatum === null || this._lastDatum.getPrice() > this._highDatum.getPrice()) {
|
||||||
|
this._highDatum = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._lowDatum === null || this._lowDatum.getPrice() > this._lastDatum.getPrice()) {
|
||||||
|
this._lowDatum = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
chartData.push({
|
chartData.push({
|
||||||
x: data[i].getX(),
|
x: data[i].getX(),
|
||||||
@ -183,7 +174,13 @@ export default class TokenChart {
|
|||||||
|
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
this._lastDatum = data[i];
|
this._lastDatum = data[i];
|
||||||
await this.#updateHighLow(data[i]);
|
if (this._highDatum === null || this._lastDatum.getPrice() > this._highDatum.getPrice()) {
|
||||||
|
this._highDatum = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._lowDatum === null || this._lowDatum.getPrice() > this._lastDatum.getPrice()) {
|
||||||
|
this._lowDatum = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
chartData.push({
|
chartData.push({
|
||||||
x: data[i].getX(),
|
x: data[i].getX(),
|
||||||
@ -292,10 +289,7 @@ export default class TokenChart {
|
|||||||
this._lowDatum = datum;
|
this._lowDatum = datum;
|
||||||
updateLowVal(this.lowDatum);
|
updateLowVal(this.lowDatum);
|
||||||
}
|
}
|
||||||
this._chart.data.datasets[0].data.push({
|
this._chart.data.datasets[0].data.push(datum);
|
||||||
x: datum.getX(),
|
|
||||||
y: datum.getY(),
|
|
||||||
});
|
|
||||||
this._chart.update();
|
this._chart.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user