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

Extra space to the right of chart #2333

Closed
moon47usaco opened this issue Apr 6, 2017 · 7 comments
Closed

Extra space to the right of chart #2333

moon47usaco opened this issue Apr 6, 2017 · 7 comments

Comments

@moon47usaco
Copy link

I would like to add extra space to the right of the chart, not the margin but in the chart itself.

Here are two screen shots of a program that has a setting for this.

The first is what I get by default in Charts and second is what I would like to get. Only extra space on the right side of the chart.

screen shot 2017-04-06 at 7 16 44 pm

screen shot 2017-04-06 at 7 17 27 pm

@liuxuan30
Copy link
Member

liuxuan30 commented Apr 10, 2017

I think it can be done by using below properties.

        self.xAxis.spaceMin = 5
        self.xAxis.spaceMax = 5

Tried in

open class LineChartView: BarLineChartViewBase, LineChartDataProvider
{
    internal override func initialize()
    {
        super.initialize()
        
        renderer = LineChartRenderer(dataProvider: self, animator: _animator, viewPortHandler: _viewPortHandler)

        self.xAxis.spaceMin = 5
        self.xAxis.spaceMax = 5
    }

result:
image

@moon47usaco
Copy link
Author

moon47usaco commented Apr 10, 2017

Is there a way to set that without editing the charts codebase?

IE editing the LineChartViw class works with self but trying

        lineChartView.xAxis.spaceMin = 100
        lineChartView.xAxis.spaceMax = 100

in the view controller has no affect.

I would prefer not to have to keep track of edits to the charts codebase that I have to reimplement when there is an update to the codebase.

@liuxuan30
Copy link
Member

well, spaceMax has no effect means you made mistakes. Try with ChartsDemo.

@moon47usaco
Copy link
Author

moon47usaco commented Apr 10, 2017

I see.

I usually have all the variables set in a function that is called from inside "viewDidLoad"

IE:

       open class LineDemoViewController: NSViewController
       {
           @IBOutlet var lineChartView: LineChartView!
    
      override open func viewDidLoad()
      {
          super.viewDidLoad()
          setData()    
      }

      func setData() {
        ...
        lineChartView.doubleTapToZoomEnabled = false
        lineChartView.xAxis.labelTextColor = NSUIColor.white
        lineChartView.xAxis.labelPosition = .bottom
        lineChartView.xAxis.spaceMax = 10
    }

It appears that this will not work like "labelPosition" and other variables and it must be set inside the "viewDidLoad()"

Why is that?

IE:

open class LineDemoViewController: NSViewController
       {
       @IBOutlet var lineChartView: LineChartView!
    
      override open func viewDidLoad()
      {
        super.viewDidLoad()
        setData()    
        lineChartView.xAxis.spaceMax = 10
    }

But this does not work for the combined chart?

open class LineDemoViewController: NSViewController
       {
       @IBOutlet var lineChartView: LineChartView!
    
      override open func viewDidLoad()
      {
        super.viewDidLoad()
        setData()    
        lineChartView.xAxis.spaceMax = 10
        combinedChartView.xAxis.spaceMax = 10
    }

@moon47usaco
Copy link
Author

moon47usaco commented Apr 10, 2017

FYI the spaceMax does not work on the iOS demo either for the combined chart.

adding _chartView.xAxis.spaceMax = 10; to the "LineChart1ViewController.m" works but not to the "CombinedChartViewController"... =[

Is there another separate variable that controls this for combined charts?

@liuxuan30
Copy link
Member

liuxuan30 commented Apr 11, 2017

combined chart does not work on my side is because in the controller, it sets axisMinimum and axisMaximum, once you comment them out, it would work:
(ignore the granularity issue)
image

@moon47usaco
Copy link
Author

Got it thank you.

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

2 participants