@@ -248,6 +248,87 @@ function () {
248248 }
249249
250250
251+ // https://github.com/AAChartModel/AAChartCore/issues/208
252+ fun doublePointsSplineChart (): AAOptions {
253+ fun createSplineDataWithCurve (point1 : DoubleArray , point2 : DoubleArray , curveOffset : Double ): Array <Any > {
254+ val x0 = point1[0 ]
255+ val y0 = point1[1 ]
256+ val x2 = point2[0 ]
257+ val y2 = point2[1 ]
258+
259+ val x1 = (x0 + x2) / 2
260+ val y1 = (y0 + y2) / 2 + curveOffset
261+
262+ return arrayOf(
263+ mapOf (" x" to x0, " y" to y0),
264+ mapOf (
265+ " x" to x1,
266+ " y" to y1,
267+ " marker" to mapOf (
268+ " enabled" to false ,
269+ " states" to mapOf (
270+ " hover" to mapOf (
271+ " enabled" to false
272+ )
273+ )
274+ ),
275+ " dataLabels" to mapOf (
276+ " enabled" to false
277+ ),
278+ " isVirtual" to true
279+ ),
280+ mapOf (" x" to x2, " y" to y2)
281+ )
282+ }
283+
284+ val dataPoint1 = doubleArrayOf(1.0 , 5.0 )
285+ val dataPoint2 = doubleArrayOf(8.0 , 15.0 )
286+ val splineData = createSplineDataWithCurve(dataPoint1, dataPoint2, 2.0 )
287+
288+ val options = AAOptions ()
289+ .chart(AAChart ()
290+ .type(AAChartType .Spline )) // Use AAChartType enum
291+ .title(AATitle ()
292+ .text(" 两点间的曲线 (中间点无交互)" ))
293+ .tooltip(AATooltip ()
294+ .useHTML(true )
295+ .formatter("""
296+ function() {
297+ if (!this.points || this.points.length === 0) {
298+ return false;
299+ }
300+
301+ let wholeContentStr = this.points[0].x + '<br/>';
302+ let length = this.points.length;
303+
304+ for (let i = 0; i < length; i++) {
305+ let thisPoint = this.points[i];
306+
307+ if (thisPoint.point && thisPoint.point.isVirtual) {
308+ return false;
309+ }
310+
311+ let yValue = thisPoint.y;
312+ if (yValue != 0) {
313+ let prefixStr = '<span style=\"' + 'color:'+ thisPoint.color + '; font-size:13px\"' + '>◉ ';
314+ wholeContentStr += prefixStr + thisPoint.series.name + ': ' + yValue + '<br/>';
315+ }
316+ }
317+ return wholeContentStr;
318+ }
319+ """ .trimIndent())) // Use triple quotes for multiline strings and trimIndent
320+ .series(arrayOf( // Use arrayOf for Kotlin arrays
321+ AASeriesElement ()
322+ .name(" Curved Line" )
323+ .data(splineData) // Convert Kotlin List/Collection to Array
324+ .marker(AAMarker ()
325+ .enabled(true )
326+ .radius(5 ))
327+ ))
328+
329+ return options
330+ }
331+
251332 fun javaScriptArrayStringWithJavaArray (javaArray : Array <String >): String {
252333 val originalJsArrStr = StringBuilder ()
253334 for (element: Any in javaArray) {
0 commit comments