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

请问tooltip可以支持放置本地图片吗? #1404

Closed
wangfang871111 opened this issue Oct 5, 2022 · 5 comments
Closed

请问tooltip可以支持放置本地图片吗? #1404

wangfang871111 opened this issue Oct 5, 2022 · 5 comments
Labels

Comments

@wangfang871111
Copy link

请问tooltip中可以放置一张本地的图片吗?

@AAChartModel
Copy link
Owner

@AAChartModel
Copy link
Owner

配置 AAOptions

- (AAOptions *)loadImageForAATooltip {
    NSArray *nameArr = @[
        @"South Korea",
        @"Japan",
        @"Australia",
        @"Germany",
        @"Russia",
        @"China",
        @"Great Britain",
        @"United States"
    ];
    
    NSArray *colorArr = @[
        AARgbColor(201, 36,  39 ),
        AARgbColor(201, 36,  39 ),
        AARgbColor(0,   82,  180),
        AARgbColor(0,   0,   0  ),
        AARgbColor(240, 240, 240),
        AARgbColor(255, 217, 68 ),
        AARgbColor(0,   82,  180),
        AARgbColor(215, 0,   38 )
    ];
    
    AAChartModel *aaChartModel = AAChartModel.new
    .chartTypeSet(AAChartTypeColumn)
    .categoriesSet(nameArr)
    .colorsThemeSet(colorArr)
    .seriesSet(@[
        AASeriesElement.new
        .nameSet(@"AD 2020")
        .dataSet(@[@9.0, @9.9, @9.5, @14.5, @18.2, @21.5, @25.2, @26.5])
        .colorByPointSet(@true)
        .borderRadiusTopLeftSet((id)@"50%")
        .borderRadiusTopRightSet((id)@"50%")
               ]);
    
    AAOptions *aaOptions = aaChartModel.aa_toAAOptions;
    aaOptions.plotOptions.column
        .groupPaddingSet(@0.005);
    
    NSString *imgFilePath = @"https://www.highcharts.com/samples/graphics/sun.png";
    //如果是加载本地图片, 使用如下👇🏻方法
    //NSString *imgFilePath = [[NSBundle mainBundle] pathForResource:@"sun" ofType:@".png"];

    /*Custom tooltip style*/
    NSString *tooltipFormatter = [NSString stringWithFormat:(@AAJSFunc(function () {
        const imageLink = "<span><img src=\"%@\" style=\"width: 30px; height: 30px;\"/></span><br/>";
        return imageLink
        + " Support JavaScript Function Just Right Now !!! <br/> "
        + " The Gold Price For <b>2020 "
        +  this.x
        + " </b> Is <b> "
        +  this.y
        + " </b> Dollars ";
    })), imgFilePath];
    
    aaOptions.tooltip
    .sharedSet(false)
    .useHTMLSet(true)
    .formatterSet(tooltipFormatter)
    ;
    
    return aaOptions;
}

最终图表

Simulator Screen Shot - iPhone 14 Pro Max - 2022-10-08 at 17 40 41

@AAChartModel
Copy link
Owner

AAChartModel commented Oct 8, 2022

如果是加载本地图片, 获取图片地址时, 使用如下👇🏻方法:

 NSString *imgFilePath = [[NSBundle mainBundle] pathForResource:@"sun" ofType:@".png"];

@wangfang871111
Copy link
Author

万分感谢~谢谢大神

@1085181361
Copy link

扇形图 数值会显示到图形区域外 导致不能展示全数值的情况出现,如何配置才能解决

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

3 participants