<commit_before>//
//  ChartYAxisRendererRadarChart.swift
//  Charts
//
//  Created by <NAME> on 3/3/15.
//
//  Copyright 2015 <NAME> & <NAME>
//  A port of MPAndroidChart for iOS
//  Licensed under Apache License 2.0
//
//  https://github.com/danielgindi/ios-charts
//

import Foundation
import CoreGraphics
import UIKit

public class ChartYAxisRendererRadarChart: ChartYAxisRenderer
{
    private weak var _chart: RadarChartView!;
    
    public init(viewPortHandler: ChartViewPortHandler, yAxis: ChartYAxis, chart: RadarChartView)
    {
        super.init(viewPortHandler: viewPortHandler, yAxis: yAxis, transformer: nil);
        
        _chart = chart;
    }
 
    public override func computeAxis(#yMin: Double, yMax: Double)
    {
        computeAxisValues(min: yMin, max: yMax);
    }
    
    internal override func computeAxisValues(min yMin: Double, max yMax: Double)
    {
        var labelCount = _yAxis.labelCount;
        var range = abs(yMax - yMin);
        
        if (labelCount == 0 || range <= 0)
        {
            _yAxis.entries = [Double]();
            return;
        }
        
        var rawInterval = range / Double(labelCount);
        var interval = ChartUtils.roundToNextSignificant(number: Double(rawInterval));
        var intervalMagnitude = pow(10.0, round(log10(interval)));
        var intervalSigDigit = Int(interval / intervalMagnitude);
        
        if (intervalSigDigit > 5)
        {
            // Use one order of magnitude higher, to avoid intervals like 0.9 or
            // 90
            interval = floor(10 * intervalMagnitude);
        }
        
        // if the labels should only show min and max
        if (_yAxis.isShowOnlyMinMaxEnabled)
        {
            _yAxis.entries = [Double]();
            _yAxis.entries.append(yMin);
            _yAxis.entries.append(yMax);
        }
        else
        {
            var first = ceil(Double(yMin) / interval) * interval;
            var last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval);
            
            var f: Double;
            var i: Int;
            var n = 0;
            for (f = first; f <= last; f += interval)<commit_msg>fix bug:_yAxis.entries will not be cleaned up in computeAxisValues<commit_after>//
//  ChartYAxisRendererRadarChart.swift
//  Charts
//
//  Created by <NAME> on 3/3/15.
//
//  Copyright 2015 <NAME> & <NAME>
//  A port of MPAndroidChart for iOS
//  Licensed under Apache License 2.0
//
//  https://github.com/danielgindi/ios-charts
//

import Foundation
import CoreGraphics
import UIKit

public class ChartYAxisRendererRadarChart: ChartYAxisRenderer
{
    private weak var _chart: RadarChartView!;
    
    public init(viewPortHandler: ChartViewPortHandler, yAxis: ChartYAxis, chart: RadarChartView)
    {
        super.init(viewPortHandler: viewPortHandler, yAxis: yAxis, transformer: nil);
        
        _chart = chart;
    }
 
    public override func computeAxis(#yMin: Double, yMax: Double)
    {
        computeAxisValues(min: yMin, max: yMax);
    }
    
    internal override func computeAxisValues(min yMin: Double, max yMax: Double)
    {
        var labelCount = _yAxis.labelCount;
        var range = abs(yMax - yMin);
        
        if (labelCount == 0 || range <= 0)
        {
            _yAxis.entries = [Double]();
            return;
        }
        
        var rawInterval = range / Double(labelCount);
        var interval = ChartUtils.roundToNextSignificant(number: Double(rawInterval));
        var intervalMagnitude = pow(10.0, round(log10(interval)));
        var intervalSigDigit = Int(interval / intervalMagnitude);
        
        if (intervalSigDigit > 5)
        {
            // Use one order of magnitude higher, to avoid intervals like 0.9 or
            // 90
            interval = floor(10 * intervalMagnitude);
        }
        
        // clean old values
        if (_yAxis.entries.count > 0)
        {
            _yAxis.entries.removeAll(keepCapacity: false);
        }
        
        // if the labels should only show min and max
        if (_yAxis.isShowOnlyMinMaxEnabled)
        {
            _yAxis.entries = [Double]();
            _yAxis.entries.append(yMin);
            _yAxis.entries.append(yMax);
        }
        else
        {
            var first = ceil(Double(yMin) / interval) * interval;
            var last = ChartUtils.nextUp(floor(Double(yMax) / interval) * interval);
            
            var f: Double;
            var i: Int;
            var n = 0;
            for (f = first; f <= last; f += interval)
{'fraction_non_alphanumeric': 0.10024128098267164, 'fraction_numerical': 0.011186663742048695, 'mean_word_length': 1.9552819183408943, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4890338', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1309, 'n_words': 347}