无论如何要从iOS中的折线图中删除导出按钮?
以下是我的代码:
HIChartView *chartView = [[HIChartView alloc] initWithFrame:self.lineGraphView2.bounds];
chartView.tintColor = [UIColor greenColor];
HIColor *color = [[HIColor alloc] initWithHexValue:@"283445"];
HIColor *greeColorHex = [[HIColor alloc] initWithHexValue:@"00B84A"];
HIColor *redColorHex = [[HIColor alloc] initWithHexValue:@"A3001F"];
// color = [color initWithHexValue:@"000000"];
HIChart *chart = [[HIChart alloc] init];
chart.plotBackgroundColor = color;
chart.backgroundColor = color;
HICredits *credits = [[HICredits alloc] init];
credits.enabled = @0;
HIExporting *exporting = [[HIExporting alloc] init];
exporting.enabled = @0;
HIOptions *options = [[HIOptions alloc]init];
options.exporting.enabled = false;
HITitle *title = [[HITitle alloc]init];
title.text = @"";
HISubtitle *subtitle = [[HISubtitle alloc]init];
// subtitle.text = @"Source: thesolarfoundation.com";
HIYAxis *yaxis = [[HIYAxis alloc]init];
yaxis.title = [[HITitle alloc]init];
yaxis.title.text = @"";
yaxis.gridLineColor = color;
yaxis.gridLineWidth = @0;
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.lineWidth = @2;
HILine *line1 = [[HILine alloc]init];
line1.name = @"Shares Price";
line1.data = graphPointsMutableArray;
line1.color = greeColorHex;
line1.threshold = @10;
HIResponsive *responsive = [[HIResponsive alloc] init];
HIRules *rules1 = [[HIRules alloc] init];
rules1.condition = [[HICondition alloc] init];
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, nil];
options.responsive = responsive;
options.chart = chart;
options.credits = credits;
options.exporting = exporting;
options.exporting.enabled = @0;
options.labels.enabled = @0;
chartView.options = options;
[self.lineGraphView2 addSubview:chartView];
我已在文档中读到设置exporting.enable = false
但它不起作用。
以下是我在Swift中找到的解决方案。基本上,您必须创建一个HINavigation对象和一个HIButtonOptions对象。将按钮选项启用属性设置为false后,将导航的按钮选项属性设置为按钮选项对象,然后将HIOptions对象的导航对象设置为您创建的导航对象。我的obj-c不足以尝试在obj-c中输入,所以下面是我的解决方案的Swift版本:
// init your options object
let options = HIOptions()
// hide hamburger button
let navigation = HINavigation() // init navigation object
let buttonOptions = HIButtonOptions() // init button options object
buttonOptions.enabled = false
navigation.buttonOptions = buttonOptions
options.navigation = navigation