Closed pankajlcx closed 2 years ago
any additional information?
Hi updated the comment, can you please check.
Any screenshot or parameters you used to create a chart and a series?
On right there should be price marker values but here not visible
This link is not available for anybody outside of your slack org. Is it possible to share an image/video directly to github?
please check
What parameters you used to create a chart and a series?
Example:
@timocov hmm, I think the right axis is default. But here it is:
version: 3.7.0
binding.chartView.api.applyOptions {
layout = LayoutOptions(
textColor = requireContext().getColorAttr(R.attr.chartText).toIntColor(),
fontSize = 10,
fontFamily = "Avenir-Roman"
)
rightPriceScale = PriceScaleOptions(borderVisible = false)
timeScale = TimeScaleOptions(
borderVisible = false,
fixLeftEdge = true,
fixRightEdge = true,
timeVisible = true,
secondsVisible = false,
tickMarkFormatter = Eval(
"""
function(time, tickMarkType, locale) {
let timeMillis = time * 1000;
let nowMillis = Date.now();
let diff = nowMillis - timeMillis;
console.log("timeMillis:", timeMillis);
console.log("nowMillis:", nowMillis);
console.log("diff:", diff);
var options = { year: 'numeric', month: 'short', day: 'numeric' };
if (diff < 86400000) {
//format timestamp, remove sec
const time = new Date(timeMillis).toLocaleTimeString('en-US', {hour12: false} ).split(':');
return time[0]+':'+time[1]
}
if (diff < 86400000 * 7) {
//format timestamp
return new Date(timeMillis).toLocaleDateString('en-US', options);
}
if (diff < 86400000 * 30) {
//format timestamp
return new Date(timeMillis).toLocaleDateString('en-US', options);
}
//format timestamp
return new Date(timeMillis).toLocaleDateString('en-US', options);
}
""".trimIndent()
)
)
crosshair = CrosshairOptions(
vertLine = CrosshairLineOptions(
style = LineStyle.DASHED,
color = ContextCompat.getColor(requireContext(), R.color.chart_crosshair)
.toIntColor(),
labelBackgroundColor = ContextCompat.getColor(
requireContext(),
R.color.chart_crosshair
).toIntColor(),
),
horzLine = CrosshairLineOptions(
style = LineStyle.DASHED,
color = ContextCompat.getColor(
requireContext(),
R.color.chart_crosshair
).toIntColor(),
labelBackgroundColor = ContextCompat.getColor(
requireContext(),
R.color.chart_crosshair
).toIntColor(),
)
)
grid = GridOptions(
vertLines = GridLineOptions(visible = false),
horzLines = GridLineOptions(
color = requireContext().getColorAttr(R.attr.chartGrid).toIntColor()
)
)
}
area:
areaSeriesOptions = AreaSeriesOptions(
lineWidth = LineWidth.TWO,
lineColor = ContextCompat.getColor(requireContext(), R.color.purple).toIntColor(),
topColor = ContextCompat.getColor(requireContext(), R.color.purple_40).toIntColor(),
bottomColor = ContextCompat.getColor(requireContext(), R.color.purple_100).toIntColor(),
)
So you're relying on the default values and expect that they will work for your specific scenario? 🙂 You have to change price format settings, see https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon#priceformat
No, I don't expect anything.
After change the price format setting, it shown the current price only. Maybe the gap between Y axis is too small. Is that any place I can config so that other price tag can be shown as well?
localization = LocalizationOptions(
priceFormatter = PriceFormatter(template = "\${price:#1:#12}")
)
Thanks for your help and the great library!
After change the price format setting, it shown the current price only. Maybe the gap between Y axis is too small. Is that any place I can config so that other price tag can be shown as well?
@namchuai from the code above you didn't change the price format, you changed the default price formatter. https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon#priceformat this is different option of a series, not of localization or a chart itself.
@timocov Thanks for your clarification. It works now! Sample code for someone stumble on the issue:
areaSeriesOptions = AreaSeriesOptions(
priceFormat = PriceFormat.priceFormatBuiltIn(
type = PriceFormat.Type.PRICE,
precision = 12,
minMove = 0.000000000001f,
),
lineWidth = LineWidth.TWO,
lineColor = ContextCompat.getColor(requireContext(), R.color.purple).toIntColor(),
topColor = ContextCompat.getColor(requireContext(), R.color.purple_40).toIntColor(),
bottomColor = ContextCompat.getColor(requireContext(), R.color.purple_100).toIntColor(),
)
for larger decimal values like 0.00004 price scale not visible in range but crosshair shows value on right price overlay