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

addCandlestickSeries custom type formatter issue #22

Open
KAEN7 opened this issue Oct 11, 2022 · 0 comments
Open

addCandlestickSeries custom type formatter issue #22

KAEN7 opened this issue Oct 11, 2022 · 0 comments

Comments

@KAEN7
Copy link

KAEN7 commented Oct 11, 2022

Describe the bug

The decimal fraction of the values in the chart corresponding to the y-axis is not regular.
ex) 1.4200, 1.32, 1.2200 ...

This is a formatter that applies logic that cuts the decimal point. We checked that the input and output values are output normally.

However, the priceFormat function within the addCandlestickSeries indicates an irregular decimal length.


To Reproduce

// LWchart.tsx

<Chart
  options={options}
  candlestickSeries={[{ data: chart }]}
  autoWidth
  height={380}
  onCrosshairMove={(param) => handleCrosshairMoved(param, chart[chart.length - 1])}
  chartRef={(chart) => {
  chart.timeScale().fitContent();
  // chart.timeScale().scrollToPosition(2, true);
  chart.addCandlestickSeries({
	  priceFormat: {
		  type: "custom",
		  formatter: (priceValue) => {
			  return decimalSplit(priceValue);
		  },
		  minMove: 0.0000000001,
	  },
  });
  }}
/>

// decimalSplit.ts
export const decimalSplit = (value: string | number) => {
	// return value;

	if (!value) return "0";
	const splitStr = String(value).split(".");
	if (!splitStr[1]) return splitStr[0];

	if (Number(splitStr[0]) > 10) {
		return `${splitStr[0]}.${splitStr[1].slice(0, 2)}`;
	} else if (Number(splitStr[0]) > 0) {
		return `${splitStr[0]}.${splitStr[1].slice(0, 4)}`;
	} else {
		return `${splitStr[0]}.${splitStr[1].slice(0, 8)}`;
	}
};

Github code => https://github.com/perifinance/peri.dex/blob/main/src/screens/Chart/LWchart.tsx


Expected behavior

The values on the y-axis must be numbers of regular length


Screenshots
스크린샷 2022-10-11 오후 8 00 57


Additional context

There was no problem with the input output value through the logic I made myself.
An issue occurs in the view group only through priceFormat.

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

1 participant