Skip to content

pebble_chart.c: chart_layer_update_layout(): check for divide-by-zero: (fMaxY - fMinY) #1

@mike23w

Description

@mike23w

hi,

there is a divide-by-zero condition in chart_layer_update_layout() that should be handled.

my y-data contains an array of zeros:
int y[] =
{0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0};

min-y and max-y are not set for the chart.

this (silently) causes a divide-by-zero error:

https://github.com/ae-code/PebbleChart/blob/master/src/pebble_chart.c#L373
const float fYScale = (float)(bounds.size.h - (2 * pData->iMargin)) / (fMaxY - fMinY);

https://github.com/ae-code/PebbleChart/blob/master/src/pebble_chart.c#L384
pData->iYTicks = (int)(fYScale * exponential10(closest_log10(fMaxY - fMinY)));

thanks, mike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions