Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Pie chart labels: using .format causes connector lines to disappear #458

Open
skuske opened this issue Feb 7, 2025 · 1 comment
Open

Comments

@skuske
Copy link

skuske commented Feb 7, 2025

With one of the latest releases a problem with pie chart labels has been introduced. When using HIDataLabels for a pie chart in combination with the format property, all connector lines disappear:

Image

If I comment out the format property, the chart does not draw at all. If I remove the HIDataLabels everything is fine and connector lines show up. See second screenshot below.

Code:

    HIChartView *chartView = [[HIChartView alloc] initWithFrame:self.view.bounds];
    
    HIOptions *options = [[HIOptions alloc]init];
    
    HIChart *chart = [[HIChart alloc]init];
    chart.type = @"pie";
    chart.options3d = [[HIOptions3d alloc]init];
    chart.options3d.enabled = [[NSNumber alloc] initWithBool:true];
    chart.options3d.alpha = @45;
    
    HITitle *title = [[HITitle alloc]init];
    title.text = @"Contents of Highsoft's weekly fruit delivery";
    
    HISubtitle *subtitle = [[HISubtitle alloc]init];
    subtitle.text = @"3D donut in Highcharts";
    
    HIPlotOptions *plotoptions = [[HIPlotOptions alloc]init];
    plotoptions.pie = [[HIPie alloc]init];
    plotoptions.pie.innerSize = @100;
    plotoptions.pie.depth = @45;
    
    HIDataLabels *dataLabels = [[HIDataLabels alloc] init];
    dataLabels.enabled=[[NSNumber alloc] initWithBool:true];
    dataLabels.align = @"right";
    dataLabels.format = @"<b>{point.name}</b>";
    dataLabels.style = [[HIStyle alloc] init];
    dataLabels.style.fontSize = @10;
        
    plotoptions.pie.dataLabels = [NSArray arrayWithObjects:dataLabels,nil];
    
    HIPie *pie = [[HIPie alloc]init];
    pie.name = @"Delivered amount";
    pie.data = [NSMutableArray arrayWithObjects:@[
                                                  @"Bananas",
                                                  @8
                                                  ],
                @[
                  @"Kiwi",
                  @3
                  ],
                @[
                  @"Mixed nuts",
                  @1
                  ],
                @[
                  @"Oranges",
                  @6
                  ],
                @[
                  @"Apples",
                  @8
                  ],
                @[
                  @"Pears",
                  @4
                  ],
                @[
                  @"Clementines",
                  @4
                  ],
                @[
                  @"Reddish (bag)",
                  @1
                  ],
                @[
                  @"Grapes (bunch)",
                  @1
                  ], nil];
    
    options.chart = chart;
    options.title = title;
    options.subtitle = subtitle;
    options.plotOptions = plotoptions;
    options.series = [NSMutableArray arrayWithObjects: pie, nil];
    
    chartView.options = options;
    
    [self.view addSubview:chartView];

No HIDataLabels:

Image

I need a solution for the most recent release that fixes the problem where the usage of HIDataLabels in combination with the format property removes all connector lines. Please note that the iOS sample at https://www.highcharts.com/demo/ios/pie-gradient also no longer works.

@skuske
Copy link
Author

skuske commented Feb 7, 2025

Update:

Using

`plotOptions.series.dataLabels = [NSArray arrayWithObjects:dataLabels,nil];`

instead of

`plotOptions.pie.dataLabels = [NSArray arrayWithObjects:dataLabels,nil];`

seems to fix the issue.

That means that plotOptions.pie.dataLabels is somewhat buggy ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant