ios-charts

IOS-Charts set maximum visible x axis values

随声附和 提交于 2019-12-01 03:20:20
I'm using ios-charts ( https://github.com/danielgindi/Charts ). I have a LineChartView with 12 values in the x axis. This however is far too many to see at the same time, so I want to display only 5 and then let the user drag to the right to see the next. I've tried this: let chart = LineChartView() chart.dragEnabled = true chart.setVisibleXRangeMaximum(5) let xAxis = chart.xAxis xAxis.axisMinValue = 0 xAxis.axisMaxValue = 5.0 xAxis.setLabelsToSkip(0) But still see all 11 values at the time. How can I only see 5? I finally got it! The correct answer is: chart.setVisibleXRangeMaximum(5) This

How to set x-axis on bar chart data - ios-charts?

﹥>﹥吖頭↗ 提交于 2019-12-01 00:43:37
Previously we can set the x-Axis of bar chart data as below:- BarChartData *data = [[BarChartData alloc] initWithXVals:xvals dataSets:dataSets]; In latest updated of ios-charts library, the syntax changed to below:- BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; How to set the x axis on BarChartData ? pkc456 With the help of this Answer (swift version) , I am able to show xAxis string values on bar chart in Objective-C . NSMutableArray *xValsDietArray; Set up your chart data. Basic example is as follows:- for (int i=0; i<dietArray.count; i++) { DietInput *obj =

Charts lineChartDataset rounded values

痴心易碎 提交于 2019-11-30 23:53:16
I'm trying out a few things with the iOS Charts library with Swift 3.0. I have a question about formatting of the lineChartDataset values (displayed above each value point). Right now these values are 'double' and are displayed as 2.0 and 3.0 instead of just 2 and 3 etc. Is it possible to round these values? I tried with numberFormatter but nothing works. Any help would be appreciated. ios-charts have been upgraded to protocol base approach for rendering the various kind of labels like xAxis, yAxis etc. So you have to implement protocol IValueFormatter in order to achieve the required results.

NSNumberFormatter : Show 'k' instead of ',000' in large numbers?

こ雲淡風輕ζ 提交于 2019-11-30 19:58:30
I'd like to change my large numbers from 100,000 to $100K if this is possible. This is what I have so far: let valueFormatter = NSNumberFormatter() valueFormatter.locale = NSLocale.currentLocale() valueFormatter.numberStyle = .CurrencyStyle valueFormatter.maximumFractionDigits = 0 My Question Using NSNumberFormatter, how can I output $100K rather than $100,000? My original question: This is what I have so far: self.lineChartView.leftAxis.valueFormatter = NSNumberFormatter() self.lineChartView.leftAxis.valueFormatter?.locale = NSLocale.currentLocale() self.lineChartView.leftAxis.valueFormatter?

How to set x-axis on bar chart data - ios-charts?

北战南征 提交于 2019-11-30 19:15:58
问题 Previously we can set the x-Axis of bar chart data as below:- BarChartData *data = [[BarChartData alloc] initWithXVals:xvals dataSets:dataSets]; In latest updated of ios-charts library, the syntax changed to below:- BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; How to set the x axis on BarChartData ? 回答1: With the help of this Answer (swift version), I am able to show xAxis string values on bar chart in Objective-C . NSMutableArray *xValsDietArray; Set up your chart

ios Charts 3.0 - Align x labels (dates) with plots

五迷三道 提交于 2019-11-30 14:54:35
I am having a hard time to migrate library Charts (from Daniel Gindi) from version 2 (Swift 2.3) to 3 (Swift 3). Basically, I can't have the x labels (dates) aligned correctly with the corresponding plots. This is what I had before in version 2: In version 2, I had values for days 7, 8, 10 and 11. So I was missing a day in the middle, but the labels were correctly alined with the plots. And here is what I have in version 3: In version 3, the "labels" in the x axis have now been replaced by double (for dates, it's a timeInterval since 1970), and formatted via a formatter. So, indeniably, the

How to add marker to center position in ios charts while scrolling horizontally with increasing scaleX and enabling drag

时光怂恿深爱的人放手 提交于 2019-11-30 10:33:53
I am using the Charts framework from Daniel Cohen Gindi. I am scrolling chart horizontally by increasing scaleX value and enabled drag as described in answer of this question Set an horizontal scroll to my Barchart in swift I want to add marker at center position when user scrolls horizontally. I know "chartTranslated" delegate is called whenever user drags the chart but it doesn't contain the value of "ChartDataEntry" and "Highlighted" like in "chartValueSelected" delegate method. Unfortunately ChartViewBase.swift is full of private function and internal vars and you can't extend some method

Convert bar chart to a grouped bar chart with danielgindi/ios-charts and Swift

若如初见. 提交于 2019-11-30 07:11:20
i have created the simple bar chart with the library at https://github.com/danielgindi/ios-charts still can't figure out how to make this a grouped bar chart. I've added the units sold array to the chart, but don't know how to get the unitBought array to the chart to make it a grouped chart.please help. @IBOutlet weak var barChartView: BarChartView! override func viewDidLoad() { super.viewDidLoad() months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 12.8] let unitsBought = [20

iOS-Charts Float to Integer YAxis

て烟熏妆下的殇ゞ 提交于 2019-11-29 10:25:45
I'm building a chart using iOS-charts I'm trying to convert the floats into int, but iOS-charts only allows for Floats in the data entry: let result = ChartDataEntry(value: Float(month), xIndex: i) Does anyone know the method for making sure only ints are used? You just need to adjust the NSNumberFormatter ... Example: yAxis.valueFormatter = NSNumberFormatter() yAxis.valueFormatter.minimumFractionDigits = 0 NSNumberFormatter is a very powerful class, you can do much much more with it. :-) For Swift 3.0 and Charts 3.0 you need to enable and set granularity for the axis. Example: barChart

How to make a grouped BarChart with ios-charts?

痴心易碎 提交于 2019-11-29 05:10:05
I am using ios-charts library. I would like to group my inverter values so that each year is one group. Unfortunately, the number of monthly values per year may vary. My data json looks like this: {"monthlyData":[{"ERTRAG":"30.2989999055862","MONAT":"2","JAHR":"2016"},{"ERTRAG":"154.897000223398","MONAT":"1","JAHR":"2016"},{"ERTRAG":"141.996000155807","MONAT":"12","JAHR":"2015"},{"ERTRAG":"135.449000149965","MONAT":"11","JAHR":"2015"},{"ERTRAG":"319.437000751495","MONAT":"10","JAHR":"2015"},{"ERTRAG":"483.369997739792","MONAT":"9","JAHR":"2015"},{"ERTRAG":"698.112997770309","MONAT":"8","JAHR":