import Highcharts
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let chartView = HIChartView(frame: view.bounds)
let options = HIOptions()
let title = HITitle()
title.text = "Combination chart"
options.title = title
let xAxis = HIXAxis()
xAxis.categories = ["Apples", "Oranges", "Pears", "Bananas", "Plums"]
options.xAxis = [xAxis]
let jane = HIColumn()
jane.name = "Jane"
jane.data = [3, 2, 1, 3, 4]
let john = HIColumn()
john.name = "John"
john.data = [2, 3, 5, 7, 6]
let joe = HIColumn()
joe.name = "Joe"
joe.data = [4, 3, 3, 9, 0]
let average = HISpline()
average.name = "Average"
average.data = [3, 2.67, 3, 6.33, 3.33]
average.marker = HIMarker()
average.marker.lineWidth = 2
average.marker.lineColor = "#f7a35c"
average.marker.fillColor = HIColor(name: "white")
let totalConsumption = HIPie()
totalConsumption.name = "Total consumption"
let janePieData = HIData()
janePieData.name = "Jane"
janePieData.y = 13
janePieData.color = HIColor(hexValue: "7cb5ec")
let johnPieData = HIData()
johnPieData.name = "John"
johnPieData.y = 23
johnPieData.color = HIColor(hexValue: "434348")
let joePieData = HIData()
joePieData.name = "joe"
joePieData.y = 19
joePieData.color = HIColor(hexValue: "90ed7d")
totalConsumption.data = [janePieData, johnPieData, joePieData]
totalConsumption.center = [100, 80]
totalConsumption.size = 100
totalConsumption.showInLegend = false
let dataLabels = HIDataLabels()
dataLabels.enabled = false
totalConsumption.dataLabels = [dataLabels]
options.series = [jane, john, joe, average, totalConsumption]
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];
HIOptions *options = [[HIOptions alloc]init];
HITitle *title = [[HITitle alloc]init];
title.text = @"Combination chart";
HIXAxis *xaxis = [[HIXAxis alloc]init];
xaxis.categories = [NSMutableArray arrayWithObjects:@"Apples",
@"Oranges",
@"Pears",
@"Bananas",
@"Plums", nil];
HIItems *item = [[HIItems alloc]init];
item.html = @"Total fruit consumption";
item.style = [[HICSSObject alloc] init];
item.style.color = @"black";
item.style.top = @"18px";
// item.style = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"50px", @"left", @"18px", @"top", @"black", @"color", nil];
HILabels *labels = [[HILabels alloc]init];
labels.items = [NSMutableArray arrayWithObject:item];
HIColumn *column1 = [[HIColumn alloc]init];
column1.name = @"Jane";
column1.data = [NSMutableArray arrayWithObjects:@3,
@2,
@1,
@3,
@4, nil];
HIColumn *column2 = [[HIColumn alloc]init];
column2.name = @"John";
column2.data = [NSMutableArray arrayWithObjects:@2,
@3,
@5,
@7,
@6, nil];
HIColumn *column3 = [[HIColumn alloc]init];
column3.name = @"Joe";
column3.data = [NSMutableArray arrayWithObjects:@4,
@3,
@3,
@9,
@0, nil];
HISpline *spline = [[HISpline alloc]init];
spline.name = @"Average";
spline.data = [NSMutableArray arrayWithObjects:@3,
@2.67,
@3,
@6.33,
@3.33, nil];
spline.marker = [[HIMarker alloc]init];
spline.marker.lineWidth = @2;
spline.marker.fillColor = [[HIColor alloc]initWithName:@"white"];
spline.marker.lineColor = [[HIColor alloc]initWithHexValue:@"f7a35c"];
HIPie *pie = [[HIPie alloc]init];
pie.name = @"Total consumption";
pie.data = [NSMutableArray arrayWithObjects:@{
@"name": @"Jane",
@"y": @13,
@"color": @"#7cb5ec"
},
@{
@"name": @"John",
@"y": @23,
@"color": @"#434348"
},
@{
@"name": @"Joe",
@"y": @19,
@"color": @"#90ed7d"
}, nil];
pie.center = [NSMutableArray arrayWithObjects:@100, @80, nil];
pie.size = @"100";
pie.showInLegend = [[NSNumber alloc] initWithBool:false];
pie.dataLabels = [[HIDataLabels alloc]init];
pie.dataLabels.enabled = [[NSNumber alloc] initWithBool:true];
options.title = title;
options.xAxis = [NSMutableArray arrayWithObject:xaxis];
options.labels = labels;
options.series = [NSMutableArray arrayWithObjects:column1, column2, column3, spline, pie, nil];
chartView.options = options;
[self.view addSubview:chartView];
}
@end