Skip to content

Commit

Permalink
Fix #970
Browse files Browse the repository at this point in the history
  • Loading branch information
AAChartModel committed Aug 28, 2024
1 parent 9396ba1 commit 7e48ad5
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions AAChartKitDemo/Demo/AAOptionsWithJS/JSFunctionForAATooltipVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ - (AAOptions *)customAreaChartTooltipStyleWithDifferentUnitSuffix {
var s = '' + '<b>' + this.x + '</b>' + '' + '<br/>';
const colorDot1 = '<span style=\"' + 'color:#1e90ff; font-size:13px\"' + '>◉</span> ';
const colorDot2 = '<span style=\"' + 'color:#ef476f; font-size:13px\"' + '>◉</span> ';
const s1 = colorDot1 + this.points[0].series.name + ': ' + this.points[0].y + '' + '<br/>';
const s2 = colorDot2 + this.points[1].series.name + ': ' + this.points[1].y + '';
const s1 = colorDot1 + this.points[0].series.name + ': ' + this.points[0].y + '' + '<br/>';
const s2 = colorDot2 + this.points[1].series.name + ': ' + this.points[1].y + '';
s += s1 + s2;
return s;
}))
Expand Down Expand Up @@ -731,22 +731,23 @@ - (AAOptions *)customAreasplineChartTooltipStyleByDivWithCSS {
.paddingSet(@0)
.borderWidthSet(@0)
.formatterSet(@AAJSFunc(function () {
var box1Text = "&nbsp 2021-" + this.x + this.points[0].series.name + this.y;
var box2Text = "&nbsp 2021-" + this.x + this.points[1].series.name + this.y;

return '<style>\
div{margin:0;padding:0}\
#container{width:300px;height:40px;border:80px;}\
#container .box1{width:150px;height:40px;float:left;background:red;line-height:40px;color:#fff}\
#container .box2{width:150px;height:40px;float:right;background:green;line-height:40px;color:#fff}\
</style>\
<div id=\"container\">'
+
'<div class=\"box1\">' + box1Text + '</div>'
+
'<div class=\"box2\">' + box2Text + '</div>'
+
'</div>';
// 获取每个点的信息
const series1Point = this.points[0];
const series2Point = this.points[1];

// 自定义的 HTML 结构
const tooltipHTML = `
<div style="display: flex; width: 100%; height: 100%;">
<div style="flex: 1; background-color: red; padding: 5px; text-align: right; color: white; margin: 0;">
<strong>${series1Point.series.name}:</strong> ${series1Point.y}
</div>
<div style="flex: 1; background-color: green; padding: 5px; text-align: left; color: white; margin: 0;">
<strong>${series2Point.series.name}:</strong> ${series2Point.y}
</div>
</div>
`;

return tooltipHTML;
}));

//禁用图例点击事件
Expand Down

0 comments on commit 7e48ad5

Please sign in to comment.