7

I am working on a graph implementation for a health app and the user can choose which fields to graph.

There are some combination of fields which never appear on the graph.

problem napkin

From the debugging I have done so far I can see that the values for all the fields are created correctly.

So ultimately my question is, why is there no line for "Weight Moving Average"

But really I would like to know how to debug this problem. What be the recommended next step for getting to the bottom of it?

Code:

if (isMovingAverage) {
        dataset.mode = LineChartModeCubicBezier;
        dataset.cubicIntensity = 0.1;
        dataset.lineWidth = 2;
        dataset.highlightEnabled = NO;
        [dataset setColor: baseColor];
        dataset.fillAlpha = 1.f;
        dataset.drawCirclesEnabled = NO;

        NSArray *gradientColors = @[
                                    (id)[UIColor whiteColor].CGColor,
                                    (id)baseColor.CGColor
                                    ];
        CGGradientRef gradient = CGGradientCreateWithColors(nil, (CFArrayRef)gradientColors, nil);

        dataset.fillAlpha = 1.f;
        dataset.fill = [ChartFill fillWithLinearGradient:gradient angle:90.f];
        dataset.drawFilledEnabled = YES;

        dataset.drawHorizontalHighlightIndicatorEnabled = NO;

        CGGradientRelease(gradient);

        NSLog(@"Dataset: %@", dataset);
    }

Debug output:

Formatting: Weight Moving Avg
2017-07-28 17:06:49.425518+0100 BodyTrackItLite[5239:1893083] Using color: UIExtendedSRGBColorSpace 0.07 0.62 0.64 1
2017-07-28 17:06:49.426723+0100 BodyTrackItLite[5239:1893083] Dataset: Charts.LineChartDataSet, label: Weight Moving Average, 140 entries
lewis
  • 2,936
  • 2
  • 37
  • 72
  • May I know what kind of data you are feeding in Dataset ? – CodeChanger Aug 09 '17 at 07:17
  • 1
    Could it be that the Weight Moving Average is completely hidden behind Total Measurements? Can you try reduce `dataset.fillAlpha` to say 0.5? – Metaphox Aug 11 '17 at 07:39
  • To start your debug process, alter your code to display 1 of the data sets, then the other, etc This will show you if there's problem with the actual data, or just the display for each individual set. Then you can start combing them. Given the 4 you could have axis scaling issues (from the data names you've got a percentage and an absolute scale?), or z-ordering (one data set is over the top of another). – cjb110 Aug 11 '17 at 07:49

1 Answers1

0

Metaphox was right in his comment, one dataset was blocking the others and so the solution was to remove the gradient fill.

I don't have a good answer as how best to approach debugging the charts component though.

lewis
  • 2,936
  • 2
  • 37
  • 72