|
@@ -11,6 +11,48 @@ import com.github.aachartmodel.aainfographics.aaoptionsmodel.AAXAxis
|
|
|
import com.github.aachartmodel.aainfographics.aatools.AAColor
|
|
|
|
|
|
object JSFunctionForAAChartEventsComposer2 {
|
|
|
+
|
|
|
+//https://github.com/AAChartModel/AAChartKit/issues/1557
|
|
|
+//https://github.com/AAChartModel/AAChartCore/issues/199
|
|
|
+//https://developer.mozilla.org/zh-CN/docs/Web/API/Touch_events/Using_Touch_Events
|
|
|
+//https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent
|
|
|
+ /*
|
|
|
+ 在 JavaScript 中,与触摸事件对应的鼠标事件分别是:
|
|
|
+
|
|
|
+ - `touchstart` 对应 `mousedown`
|
|
|
+ - `touchend` 对应 `mouseup`
|
|
|
+
|
|
|
+ 因此,将你的代码中的触摸事件改为鼠标事件后,代码可以改写为:
|
|
|
+
|
|
|
+
|
|
|
+ 1.
|
|
|
+ ```javascript
|
|
|
+ // 监听 mousedown 事件
|
|
|
+ container.addEventListener('mousedown', function() {
|
|
|
+ hideDataLabels(chart);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听 mouseup 事件
|
|
|
+ container.addEventListener('mouseup', function() {
|
|
|
+ showDataLabels(chart);
|
|
|
+ });
|
|
|
+ ```
|
|
|
+
|
|
|
+ 或者也可以改成为:
|
|
|
+
|
|
|
+ 2.
|
|
|
+ ```javascript
|
|
|
+ // 监听 mouseenter 事件
|
|
|
+ container.addEventListener('mouseenter', function() {
|
|
|
+ hideDataLabels(chart);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听 mouseleave 事件
|
|
|
+ container.addEventListener('mouseleave', function() {
|
|
|
+ showDataLabels(chart);
|
|
|
+ });
|
|
|
+ ```
|
|
|
+ */
|
|
|
fun toggleDataLabelsOnTouch(): AAOptions {
|
|
|
val options = AAOptions()
|
|
|
.chart(AAChart()
|