ios - 我们可以使用 HighCharts 重叠多个图表吗

标签 ios charts highcharts overlapping

我想使用 HighCharts 库重叠多个图表。我怎样才能做到这一点?

enter image description here

最佳答案

是的,你可以。

检查下面的链接以获得演示和代码(您可以在下面找到相同的代码),

https://www.highcharts.com/ios/demo/line-basic

#import <UIKit/UIKit.h>
#import <Highcharts/Highcharts.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    HIChartView *chartView = [[HIChartView alloc] initWithFrame:self.view.bounds];

    HIOptions *options = [[HIOptions alloc]init];

    HITitle *title = [[HITitle alloc]init];
    title.text = @"Solar Employment Growth by Sector, 2010-2016";

    HISubtitle *subtitle = [[HISubtitle alloc]init];
    subtitle.text = @"Source: thesolarfoundation.com";

    HIYAxis *yaxis = [[HIYAxis alloc]init];
    yaxis.title = [[HITitle alloc]init];
    yaxis.title.text = @"Number of Employees";

    HILegend *legend = [[HILegend alloc]init];
    legend.layout = @"vertical";
    legend.align = @"right";
    legend.verticalAlign = @"middle";

    HIPlotOptions *plotoptions = [[HIPlotOptions alloc] init];
    plotoptions.series = [[HISeries alloc] init];
    plotoptions.series.label = [[HILabel alloc] init];
    plotoptions.series.label.connectorAllowed = [[NSNumber alloc] initWithBool:false];
    plotoptions.series.pointStart = @2010;

    HILine *line1 = [[HILine alloc]init];
    line1.name = @"Installation";
    line1.data = [NSMutableArray arrayWithObjects:@43934, @52503, @57177, @69658, @97031, @119931, @137133, @154175, nil];

    HILine *line2 = [[HILine alloc]init];
    line2.name = @"Manufacturing";
    line2.data = [NSMutableArray arrayWithObjects:@24916, @24064, @29742, @29851, @32490, @30282, @38121, @40434, nil];

    HILine *line3 = [[HILine alloc]init];
    line3.name = @"Sales & Distribution";
    line3.data = [NSMutableArray arrayWithObjects:@11744, @17722, @16005, @19771, @20185, @24377, @32147, @39387, nil];

    HILine *line4 = [[HILine alloc]init];
    line4.name = @"Project Development";
    line4.data = [NSMutableArray arrayWithObjects:[NSNull null], [NSNull null], @7988, @12169, @15112, @22452, @34400, @34227, nil];

    HILine *line5 = [[HILine alloc]init];
    line5.name = @"Other";
    line5.data = [NSMutableArray arrayWithObjects:@12908, @5948, @8105, @11248, @8989, @11816, @18274, @18111, nil];

    HIResponsive *responsive = [[HIResponsive alloc] init];

    HIRules *rules1 = [[HIRules alloc] init];
    rules1.condition = [[HICondition alloc] init];
    rules1.condition.maxWidth = @500;
    rules1.chartOptions = @{
                            @"legend" : @{
                                            @"layout": @"horizontal",
                                            @"align": @"center",
                                            @"verticalAlign": @"bottom"
                                        }

                            };
    responsive.rules = [NSMutableArray arrayWithObjects:rules1, nil];

    options.title = title;
    options.subtitle = subtitle;
    options.yAxis = [NSMutableArray arrayWithObject:yaxis];
    options.legend = legend;
    options.plotOptions = plotoptions;
    options.series = [NSMutableArray arrayWithObjects:line1, line2, line3, line4, line5, nil];
    options.responsive = responsive;

    chartView.options = options;

    [self.view addSubview:chartView];
}

@end

关于ios - 我们可以使用 HighCharts 重叠多个图表吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49129980/

相关文章:

ios - NSLayoutConstraints 的 UIViewPropertyAnimator 使 View 消失

ios - 可以使用 Xcode 11 beta 6 在 AppStore 中提交应用程序吗?

ios - iOS 图表中的缩放轴(适用于 iOS 的 MPAndroidChart)

css - 更改 Highmap 的颜色

javascript - React 0.13.3 和 React-highcharts 3.0.0 的 Nodata 消息

ios - ARC如何知道保留单例对象?

ios - 如果应用程序不在前台,DownloadTask 在作为后台获取的一部分执行时会暂停吗?

javascript - AmCharts 序列图 : Center-align label under the axis points

ios - iOS 图表库的问题

highcharts - 反转 Highcharts 中的 Y 轴