当 y 轴值较小时,烛台显示效果不佳

Candlestick doesn't display well when the y-axis values are small

我在 android 应用程序上使用 SciChart 来显示烛台图表。当 y 值很大时,图表可以很好地显示数据。

但当y值较小时,图表显示效果不佳。它具有默认比例级别。您可以在底部看到值(red/green 点),非常接近 y=0

即使我尝试增加缩放级别,它似乎也有缩放级别的限制。

任何人都可以给我一些解决这个问题的想法。

下面是我当前的实现

private fun getOhlcDataSeries(symbolValues: List<SymbolValue>):
        OhlcDataSeries<Date, Double> {
    val dataSeries = OhlcDataSeries(Date::class.java, Double::class.javaObjectType)

    val dates = symbolValues.map { it.timePeriodStart }
    val opens = symbolValues.map { it.priceOpen }
    val high = symbolValues.map { it.priceHigh }
    val lows = symbolValues.map { it.priceLow }
    val closes = symbolValues.map { it.priceClose }

    dataSeries.append(dates, opens, high, lows, closes)
    return dataSeries
}

val sciChartBuilder = SciChartBuilder.instance()
    val priceSeries = getData()

    val xAxis = sciChartBuilder.newCategoryDateAxis().build()
    val yAxis = sciChartBuilder.newNumericAxis().build()

    val dataSeries = getOhlcDataSeries(priceSeries)

    val upColor = 0xFF64AA6F.toInt()
    val downColor = 0xFFE25C5A.toInt()

    val rSeries = sciChartBuilder.newCandlestickSeries()
            .withStrokeUp(upColor)
            .withFillUpColor(upColor)

            .withStrokeDown(downColor)
            .withFillDownColor(downColor)

            .withDataSeries(dataSeries)
            .build()

    UpdateSuspender.using(surface) {
        Collections.addAll(surface.xAxes, xAxis)
        Collections.addAll(surface.yAxes, yAxis)
        Collections.addAll(surface.renderableSeries, rSeries)
        Collections.addAll(surface.chartModifiers, sciChartBuilder.newModifierGroupWithDefaultModifiers().build())
    }

谢谢

您是否尝试过使用 AutoRange.Always 作为您的 y 轴?

val yAxis = sciChartBuilder.newNumericAxis().withAutoRangeMode(AutoRange.Always).build()

每次绘制图表时,它应该强制 yAxis 应用自动范围以适应屏幕上的数据。

披露:我是 SciChart Android 团队的首席开发人员

我尝试了很多解决方案,最后,添加这个就可以了

    yAxis.minimalZoomConstrain = 0.00000001
    yAxis.maximumZoomConstrain = 1000000