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

Y轴数据为0时,滑动手势导致marker只能显示上半部分 #166

Closed
dudukee opened this issue Mar 21, 2023 · 9 comments
Closed
Labels

Comments

@dudukee
Copy link
Contributor

dudukee commented Mar 21, 2023

device-2023-03-21-170403.mp4

初始化显示没问题,触发滑动之后只能显示一半(上半部分)。

最初是在配置可滚动图表发现的问题,测试后发现与是否可滚动无关。

Demo中的model数据如下:

val aaChartModel =
            AAChartModel.Builder(this).setChartType(AAChartType.Spline).setTitle("")
                .setYAxisTitle("").setYAxisVisible(false).setLegendEnabled(false)
                .setTooltipEnabled(true).setYAxisGridLineWidth(0f)
                .setSeries(
                    AASeriesElement()
                        .states(AAStates().hover(AAHover().halo(AAHalo().size(0)).enabled(true).lineWidthPlus(0f)))
                        .marker(
                            AAMarker().enabled(true).radius(4f).fillColor(AAColor.Black).states(
                                AAMarkerStates().hover(
                                    AAMarkerHover().enabled(true).radiusPlus(1f)
                                        .fillColor(AAColor.White).lineWidthPlus(1f)
                                )
                            )
                        ).lineWidth(2f)
                        .data(arrayOf(0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0))
                )
                .build()

请问有办法改成正常显示吗?

@AAChartModel
Copy link
Owner

这个十有八九是 Highcharts 自身的 bug, 估计解决不了

@AAChartModel
Copy link
Owner

AAChartModel commented Mar 21, 2023

试试 AAXAxis 的属性 offset, 类似 JS 这样配置:

Highcharts.chart('container', {

    chart: {
        marginLeft: 120
    },

    title: {
        text: 'Axes offset by 10px'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        offset: 10,
        lineWidth: 2
    },
  
    series: [{
        type: 'spline',
        data: [29.9, 71.5, 0, 0, 0, 450.0, 135.6, 148.5, 216.4, 0, 0, 0]
    }]

});

截屏2023-03-21 17 57 30

@AAChartModel
Copy link
Owner

文档参考链接: https://api.highcharts.com/highcharts/xAxis.offset

@AAChartModel
Copy link
Owner

以上 JS 配置对应的 Kotlin 代码如下:

fun configureXAxisOffsetForAAOptions(): AAOptions {
    return AAOptions()
        .chart(AAChart()
            .marginLeft(120f))
        .title(AATitle()
            .text("Axes offset by 10px"))
        .xAxis(AAXAxis()
            .categories(arrayOf(
                "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
            .offset(10f)
            .lineWidth(2f))
        .series(arrayOf(
            AASeriesElement()
                .type(AAChartType.Spline)
                .data(arrayOf(
                    29.9, 71.5, 0, 0, 0, 450.0, 135.6, 148.5, 216.4, 0, 0, 0))))
}

@dudukee
Copy link
Contributor Author

dudukee commented Mar 21, 2023

感谢回复,我目前使用的版本(AAChartCore-Kotlin-7.2.0)没有offset这个属性,有一个off属性设置之后无效。尝试修改源码off->offset之后可以生效。

@AAChartModel
Copy link
Owner

我目前使用的版本(AAChartCore-Kotlin-7.2.0)没有offset这个属性

这个应该是我属性写错了, 后面改一下

@dudukee
Copy link
Contributor Author

dudukee commented Mar 21, 2023

好的,我看到PR被合并了,你测下没问题能不能抽时间发个小版本,多谢。另外这个issue你可以择机关闭 😄

@AAChartModel
Copy link
Owner

加好 tag 了, 新的 tag 值为 7.2.1 你更新一下试试:

	dependencies {
	        implementation 'com.github.AAChartModel:AAChartCore-Kotlin:7.2.1'
	}

@dudukee
Copy link
Contributor Author

dudukee commented Mar 22, 2023

更新7.2.1之后,offset属性没问题了。

但是发现了一个新问题,followTouchMove(false)时如果点击展示了tooltip还会出现坐标点只能展示一半的问题。而如果设置了followTouchMove(true)又会导致:快速滑动曲线图时,tooltip依然展示旧值的问题。不知道这个问题有什么解决办法吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants