import Highcharts
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let chartView = HIChartView(frame: view.bounds)
let options = HIOptions()
let chart = HIChart()
chart.type = "column"
options.chart = chart
let title = HITitle()
title.text = "Column chart with negative values"
options.title = title
let xAxis = HIXAxis()
xAxis.categories = ["Apples", "Oranges", "Pears", "Grapes", "Bananas"]
options.xAxis = [xAxis]
let credits = HICredits()
credits.enabled = false
options.credits = credits
let john = HIColumn()
john.name = "John"
john.data = [5, 3, 4, 7, 2]
let jane = HIColumn()
jane.name = "Jane"
jane.data = [2, -2, -3, 2, 1]
let joe = HIColumn()
joe.name = "Joe"
joe.data = [3, 4, 4, -2, 5]
options.series = [john, jane, joe]
chartView.options = optionss
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];
HIChart *chart = [[HIChart alloc]init];
chart.type = @"column";
HITitle *title = [[HITitle alloc]init];
title.text = @"Column chart with negative values";
HIXAxis *xaxis = [[HIXAxis alloc]init];
xaxis.categories = [NSMutableArray arrayWithObjects:@"Apples",
@"Oranges",
@"Pears",
@"Grapes",
@"Bananas", nil];
HICredits *credits = [[HICredits alloc]init];
credits.enabled = [[NSNumber alloc] initWithBool:false];
HIColumn *column1 = [[HIColumn alloc]init];
column1.name = @"John";
column1.data = [NSMutableArray arrayWithObjects:@5,
@3,
@4,
@7,
@2, nil];
HIColumn *column2 = [[HIColumn alloc]init];
column2.name = @"Jane";
column2.data = [NSMutableArray arrayWithObjects:@2,
@-2,
@-3,
@2,
@1, nil];
HIColumn *column3 = [[HIColumn alloc]init];
column3.name = @"Joe";
column3.data = [NSMutableArray arrayWithObjects:@3,
@4,
@4,
@-2,
@5, nil];
options.chart = chart;
options.title = title;
options.xAxis = [NSMutableArray arrayWithObjects:xaxis, nil];
options.credits = credits;
options.series = [NSMutableArray arrayWithObjects: column1, column2, column3, nil];
chartView.options = options;
[self.view addSubview:chartView];
}
@end