I want to customize the class that uses internal within the module.

Asked 2 years ago, Updated 2 years ago, 41 views

I use a framework called Charts.I installed it with Cocoapods.

I would like to change the RadarChartView display.To do so, you must change the RadarChartRenderer.

In RadarChartView,

internal override func initialize()
{
    super.initialize()

    _yAxis=YAxis (position: .left)

    render = RadarChartRenderer (chart:self, animator:_animator, viewPortHandler:_viewPortHandler)

    _yAxisRenderer=YAxisRendererRadarChart (viewPortHandler:_viewPortHandler, yAxis:_yAxis, chart:self)
    _xAxisRenderer=XAxisRendererRadarChart (viewPortHandler:_viewPortHandler, xAxis:_xAxis, chart:self)

    self.highlighter=RadarHighlighter (chart:self)
}

render in is an instance of RadarChartRender.First of all, initialize is an internal specification, so you cannot override it. render is

open class ChartViewBase:NSUIView, ChartDataProvider, AnimatorDelegate
{
    ...

    /// object responsible for rendering the data
    open var render —DataRender?

    ...
}

Therefore, since it is open, I think I can replace it with a custom render.but

 render = RadarChartRender (chart:self, animator:_animator, viewPortHandler:_viewPortHandler)

The _animator and _viewPortHandler used in are internal, so you cannot give the required parameters in the subclass or extension of RadarChartView.

Many people, not just me, seem to have these questions.

There are many other things.This is a 2015 pull request, so it may not be possible to adopt it.

If you have any good ideas, I'd like to ask for your advice.Thank you for your cooperation.

Currently, we use the rough method of rewriting modules directly.

It may have been difficult to understand because I didn't write down exactly what I wanted to do.

"My boss asked me to give ""!"" to the most recessed part on the radar chart."For example, show your test results on a radar chart, and if your English score is the lowest, show "!" there.

The only way to do this is to change the RadarChartRenderer, and to use the custom RadarChartRenderer, you must also change the render in RadarChartView.

Although the entire class is open, the Charts library has many internal specifications, making it virtually difficult to customize.

swift ios

2022-09-30 15:43

1 Answers

I can't change RadarChartRenderer, but I'll give you an example of how I want to change the display, which is a root problem.

Charts Ver 3.0.1

import UIKit
import Charts

classViewController:UIViewController {

@IBOutlet weak varradarChartView: RadarChartView!

override func viewDidLoad(){
    super.viewDidLoad()
    let titles = ["Coffee", "Black Tea", "Cocoa", "Hoji Tea", "Green Tea", "Brown Tea", "Pure Tea", "Gobo Tea", "Hamugi Tea"]
    varentries1 = RadarChartDataEntry()
    varentries2 = RadarChartDataEntry()

   // Taste and popularity scores
    for_in0...title.count {
        let double1 = 80.0
        let double2 = 20.0
        let entry1 = RadarChartDataEntry (value:double1)
        let entry2 = RadarChartDataEntry (value:double2)
        entries1.append(entry1)
        entries2.append(entry2)
    }

    let set1 = RadarChartDataSet(values:entries1, label: "taste")
    set1.colors=[UIColor.white]

    let set2 = RadarChartDataSet (values: entries2, label: "popular")
    set2.drawFiledEnabled=true
    set2.valueColors=[UIColor.blue]
    set2.fillColor=UIColor.white

    // You can erase all the scales, lines, and things that are described.
    set2.drawValuesEnabled=false

    let data = RadarChartData (dataSets: [set1, set2])
    radarChartView.data=data

    radarChartView.backgroundColor=UIColor.lightGray

    // It seems that the title of the axis has changed since Ver3.0.
    radarChartView.xAxis.valueFormatter=IndexAxisValueFormatter(values:title)

    // Maximum and minimum points
    radarChartView.yAxis.axisMinimum=0
    radarChartView.yAxis.axisMaximum=100

    radarChartView.minOffset=64

    radarChartView.yAxis.drawLabelsEnabled=false
    radarChartView.chartDescription?.text="Unit: Points"

    radarChartView.animate (xAxisDuration: 3.5)

}

override funcdidReceiveMemoryWarning(){
    super.didReceiveMemoryWarning()
}


}

Please note that the details have changed as the version has been upgraded.
If you build this
build image
This is what happens.
I tried to answer as much as I could, but what do you think?


2022-09-30 15:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.