import Highcharts
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let chartView = HIChartView(frame: view.bounds)
chartView.plugins = ["variable-pie"]
let options = HIOptions()
let chart = HIChart()
chart.type = "variablepie"
options.chart = chart
let title = HITitle()
title.text = "Countries compared by population density and total area."
options.title = title
let tooltip = HITooltip()
tooltip.headerFormat = ""
tooltip.pointFormat = "<span style=\"color:{point.color}\">\u{25CF}</span> <b> {point.name}</b><br/>' + 'Area (square km): <b>{point.y}</b><br/>' + 'Population density (people per square km): <b>{point.z}</b><br/>"
options.tooltip = tooltip
let countries = HIVariablepie()
countries.minPointSize = 10
countries.innerSize = "20%"
countries.zMin = 0
countries.name = "countries"
let spain = HIData()
spain.name = "Spain"
spain.y = 505370
spain.z = 92.9
let france = HIData()
france.name = "France"
france.y = 551500
france.z = 118.7
let poland = HIData()
poland.name = "Poland"
poland.y = 312685
poland.z = 124.6
let czechRepublic = HIData()
czechRepublic.name = "Czech Republic"
czechRepublic.y = 78867
czechRepublic.z = 137.5
let italy = HIData()
italy.name = "Italy"
italy.y = 301340
italy.z = 201.8
let switzerland = HIData()
switzerland.name = "Switzerland"
switzerland.y = 41277
switzerland.z = 214.5
let germany = HIData()
germany.name = "Germany"
germany.y = 357022
germany.z = 235.6
countries.data = [spain, france, poland, czechRepublic, italy, switzerland, germany]
options.series = [countries]
chartView.options = options
self.view.addSubview(chartView)
}
}
#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];
chartView.plugins = @[ @"variable-pie" ];
HIOptions *options = [[HIOptions alloc] init];
HIChart *chart = [[HIChart alloc] init];
chart.type = @"variablepie";
HITitle *title = [[HITitle alloc] init];
title.text = @"Countries compared by population density and total area.";
HITooltip *tooltip = [[HITooltip alloc] init];
tooltip.headerFormat = @"";
tooltip.pointFormat = @"<span style=\"color:{point.color}\">\u25CF</span> <b> {point.name}</b><br/>Area (square km): <b>{point.y}</b><br/>Population density (people per square km): <b>{point.z}</b><br/>";
HIVariablepie *variablepie = [[HIVariablepie alloc] init];
variablepie.minPointSize = @10;
variablepie.innerSize = @"20%";
variablepie.zMin = @0;
variablepie.name = @"countries";
variablepie.data = @[
@{
@"name": @"Spain",
@"y": @505370,
@"z": @92.9
}, @{
@"name": @"France",
@"y": @551500,
@"z": @118.7
}, @{
@"name": @"Poland",
@"y": @312685,
@"z": @124.6
}, @{
@"name": @"Czech Republic",
@"y": @78867,
@"z": @137.5
}, @{
@"name": @"Italy",
@"y": @301340,
@"z": @201.8
}, @{
@"name": @"Switzerland",
@"y": @41277,
@"z": @214.5
}, @{
@"name": @"Germany",
@"y": @357022,
@"z": @235.6
}
];
options.chart = chart;
options.title = title;
options.tooltip = tooltip;
options.series = [NSMutableArray arrayWithObjects:variablepie, nil];
chartView.options = options;
[self.view addSubview:chartView];
}
@end