Skip to content

Commit

Permalink
feat: hide empty bars (#276)
Browse files Browse the repository at this point in the history
* feat: hide empty bars

* fix: remove clo
  • Loading branch information
quangdz1704 authored Jun 5, 2024
1 parent 1c02a9b commit 91e033f
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/oraidex-common-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oraichain/oraidex-common-ui",
"version": "1.0.19",
"version": "1.0.20",
"files": [
"dist/"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default function TVChartContainer({

await checkChartReady();

tvWidgetRef.current.onChartReady(function () {
tvWidgetRef.current.onChartReady(async function () {
setChartReady(true);
tvWidgetRef.current!.applyOverrides({
...defaultChartProps.overrides,
Expand All @@ -190,8 +190,8 @@ export default function TVChartContainer({
}
});

// create indicator
activeChart.createStudy("Volume");
// create indicator // TODO: not used when datafeed.resolveSymbol has option: `has_no_volume: false,`
// await activeChart.createStudy("Volume");
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ const chartOverrides = {
"paneProperties.vertGridProperties.style": 2,
"paneProperties.horzGridProperties.style": 2,
"mainSeriesProperties.priceLineColor": "#3a3e5e",

"mainSeriesProperties.showCountdown": false,

"mainSeriesProperties.barStyle.dontDrawOpen": true,
"mainSeriesProperties.candleStyle.barColorsOnPrevClose": false,
"mainSeriesProperties.hollowCandleStyle.drawWick": false,
"mainSeriesProperties.haStyle.barColorsOnPrevClose": false,
// "paneProperties.legendProperties.showSeriesTitle": false,
"paneProperties.legendProperties.showSeriesOHLC": true,
"paneProperties.legendProperties.showStudyTitles": true,
// "paneProperties.legendProperties.showStudyValues": true,
"paneProperties.topMargin": 12,
"paneProperties.bottomMargin": 2,
"scalesProperties.fontSize": 12,
"scalesProperties.showSymbolLabels": false,
"scalesProperties.showStudyLastValue": false,
...chartStyleOverrides
};

Expand Down Expand Up @@ -105,7 +121,8 @@ const enabledFeatures = [
"hide_left_toolbar_by_default",
"create_volume_indicator_by_default",
"use_localstorage_for_settings",
"save_chart_properties_to_local_storage"
"save_chart_properties_to_local_storage",
"study_templates"
];

export const defaultChartProps = {
Expand All @@ -123,6 +140,10 @@ export const defaultChartProps = {
favorites: {
intervals: FAVORITES_INTERVAL
},
drawings_access: {
type: "black" as "black" | "white",
tools: [{ name: "Regression Trend", grayed: true }]
},
custom_formatters: {
timeFormatter: {
format: (date) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class TVDataProvider {
const { from, to, countBack } = periodParams;
const toWithOffset = to;
const fromWithOffset = from;
const bars = barsInfo.data.filter((bar) => bar.time > fromWithOffset && bar.time <= toWithOffset);
const bars = barsInfo.data.filter((bar) => bar.volume && bar.time > fromWithOffset && bar.time <= toWithOffset);

// if no bars returned, return empty array
if (!bars.length) {
Expand Down Expand Up @@ -103,6 +103,7 @@ export class TVDataProvider {
baseUrl,
fetchDataChart
});

return bars.sort((a, b) => a.time - b.time).map(formatTimeInBarToMs);
} catch (e) {
console.error("getBars", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export default function useTVDatafeed({
visible_plots_set: "ohlc",
data_status: "streaming",
exchange: EXCHANGE_NAME,
has_empty_bars: true
has_no_volume: false,
has_empty_bars: false // show - hide bar has empty volume,
};
setTimeout(() => onSymbolResolvedCallback(symbolInfo));
},
Expand Down
50 changes: 34 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5318,6 +5318,11 @@
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==

"@types/lru-cache@^4.1.1":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-4.1.3.tgz#ec5eb6dd818b7a06336cfb7368723164b195f818"
integrity sha512-QjCOmf5kYwekcsfEKhcEHMK8/SvgnneuSDXFERBuC/DPca2KJIO/gpChTsVb35BoWLBpEAJWz1GFVEArSdtKtw==

"@types/lru-cache@^5.1.0":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.1.tgz#c48c2e27b65d2a153b19bfc1a317e30872e01eef"
Expand Down Expand Up @@ -6334,14 +6339,22 @@ available-typed-arrays@^1.0.7:
dependencies:
possible-typed-array-names "^1.0.0"

axios-extensions@^3.1.3:
version "3.1.6"
resolved "https://registry.yarnpkg.com/axios-extensions/-/axios-extensions-3.1.6.tgz#bfa72f65f44f0a3efa55a030cdaaa6451c246b1e"
integrity sha512-CmwMYxxAw4DcQDJ7/2Iv4GJj1Ao48lJEPieycgZQH6m1KcYZqf9zm2HM/CsULqheCpYxZbiGrCfZf5tVjXqoLg==
[email protected]:
version "3.1.3"
resolved "https://registry.yarnpkg.com/axios-extensions/-/axios-extensions-3.1.3.tgz#cd745bb7dc899743f85a2b5a291c7f36d9f41e12"
integrity sha512-/OB9OcJLNOIx9pdW4m4/hFRvNo12wlX5BaprIzqpMaLR02I88Mr98/wW4QN9rhx0/yg9rM7i6Af/RpV4MyxXjA==
dependencies:
lru-cache "^7.14.0"
tslib "^2.1.0"
util "^0.12.3"
"@types/lru-cache" "^4.1.1"
lru-cache "^5.1.1"
tslib "^1.9.0"
util "^0.11.1"

[email protected], axios@^0.26.1:
version "0.26.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
dependencies:
follow-redirects "^1.14.8"

axios@^0.21.1, axios@^0.21.2:
version "0.21.4"
Expand All @@ -6350,13 +6363,6 @@ axios@^0.21.1, axios@^0.21.2:
dependencies:
follow-redirects "^1.14.0"

axios@^0.26.1:
version "0.26.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9"
integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==
dependencies:
follow-redirects "^1.14.8"

axios@^0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
Expand Down Expand Up @@ -10539,6 +10545,11 @@ inherits@2, [email protected], inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, i
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==

[email protected]:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ini/-/ini-4.1.1.tgz#d95b3d843b1e906e56d6747d5447904ff50ce7a1"
Expand Down Expand Up @@ -16166,7 +16177,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

tslib@^1.13.0, tslib@^1.9.3:
tslib@^1.13.0, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
Expand Down Expand Up @@ -16569,7 +16580,14 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==

util@^0.12.3, util@^0.12.4:
util@^0.11.1:
version "0.11.1"
resolved "https://registry.yarnpkg.com/util/-/util-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61"
integrity sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ==
dependencies:
inherits "2.0.3"

util@^0.12.4:
version "0.12.5"
resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc"
integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==
Expand Down

0 comments on commit 91e033f

Please sign in to comment.