amcharts / amcharts4

The most advanced amCharts charting library for JavaScript and TypeScript apps.
https://www.amcharts.com/
1.16k stars 322 forks source link

[Question] Multiple CandlestickSeries is shifted relative to each other #4395

Closed decadence closed 7 months ago

decadence commented 7 months ago

I have XYChart with multiple LineSeries (hidden on image) and multiple CandlestickSeries. I don't know why but candles are shifted relative to each other (on DateAxis) even they have equal date (start of hour).

2024-04-16_15-55-46

If I add only one CandlestickSeries it appears normal

image

What can I do about it so candles will have equal position on DateAxis and normal width of the candle (for whole hour)?

This is how I add CandlestickSeries:

for (let candle of this.candles) {
    let series = chart.series.push(new am4charts.CandlestickSeries());
    series.dataFields.dateX = this.dateField;
    series.name = candle.name;
    series.dataFields.valueY = candle.values.close;
    series.dataFields.openValueY = candle.values.open;
    series.dataFields.lowValueY = candle.values.low;
    series.dataFields.highValueY = candle.values.high;
    series.simplifiedProcessing = false;
    series.tooltipText = "Open: {openValueY.value}\nLow: {lowValueY.value}\nHigh: {highValueY.value}\nClose: {valueY.value}";

    scrollbar.series.push(series);
    series.events.disableType("selectionextremeschanged");

    // with break we can add only one CandlestickSeries and it appears as expected
    // break;
}
martynasma commented 7 months ago

You can disable clustering on a series:

series.clustered = false;

https://www.amcharts.com/docs/v4/reference/candlestickseries/#clustered_property

decadence commented 7 months ago

@martynasma thanks for the fast response. It works, didn't notice this property when I searched in docs.