AAChartModel / AAChartKit-Swift-Pro

📈📊👑👑👑AAChartKit-Swift-Pro is a professional version of AAChartKit-Swift, it is an elegant and friendly chart framework for iOS, iPadOS, macOS. AAChartKit-Swift-Pro is a more powerful data visualization framework that supports more types beautiful chart like bellcurve, bullet, columnpyramid, cylinder, dependencywheel, heatmap, histogram, networkgraph, organization, packedbubble, pareto, sankey, series, solidgauge, streamgraph, sunburst, tilemap, timeline, treemap, variablepie, variwide, vector, venn, windbarb, wordcloud, xrange charts and so on.
36 stars 10 forks source link

xrange类型图表可以自定义x轴坐标和tooltip内容吗? #7

Closed LoseRecall closed 5 months ago

LoseRecall commented 5 months ago

tooltip显示起始时间,x轴有对应时间坐标,可以实现吗?大佬!

AAChartModel commented 5 months ago

有设计稿吗?

LoseRecall commented 5 months ago

类似这种

企业微信20240515-113245@2x
AAChartModel commented 5 months ago

参考:

将参考链接里的这个在线示例, 其中 tooltipformatter 改成下面这样:

formatter: function () {
    var start = Highcharts.dateFormat('%H:%M', this.point.x);
    var end = Highcharts.dateFormat('%H:%M', this.point.x2);
    var duration = (this.point.x2 - this.point.x) / (1000 * 60); // Calculate duration in minutes
    var tooltipTitle = '<b>浅睡 <span style="font-weight:bold;font-size:22px;">' + duration + '</span> 分钟</b>';
    return tooltipTitle + '<br/>' + start + ' - ' + end;
}

运行后, tooltip 出来的内容格式效果, 参照你的设计稿, 就算是比较接近了.

截屏2024-05-15 14 14 56
AAChartModel commented 5 months ago

另外, 参考这个相关提问:

你甚至可以直接通过 iOS 的原生代码, 自己绘制 crosshair 准星线tooltip 浮动提示框.

如果你的自定义效果比较特殊复杂的话, 可以使用这个方法. 简单一点的话, 上面的那种方法就基本满足需求了.

AAChartModel commented 5 months ago

另外参考相关问题: