1

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

当 y 值较大时,图表显示良好。

但是当 y 值较小时,图表显示效果不佳。它具有默认的比例级别。您可以在底部看到值(红色/绿色点),非常接近 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())
    }

谢谢

4

2 回答 2

2

我尝试了很多解决方案,最后,它通过添加这个来工作

    yAxis.minimalZoomConstrain = 0.00000001
    yAxis.maximumZoomConstrain = 1000000
于 2018-03-03T17:16:40.967 回答
0

您是否尝试将AutoRange.Always用于您的 yAxis?

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

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

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

于 2018-03-03T14:52:51.873 回答