@@ -23,22 +23,32 @@ class ViewController: UIViewController {
2323 unitOfMeasure: " years " )
2424 scatterChartData. xAxisUnitOfMeasure = " days of birth "
2525
26- chartView. setup ( data: scatterChartData , type : . scatter ( dotDiameter : 8 ) )
26+ chartView. setup ( data: FLChartData ( title : " Line " , data : monthsData , legendKeys : [ Key ( key : " 1 " , color : . green ) , Key ( key : " 2 " , color : . blue ) , Key ( key : " 3 " , color : . red ) ] , unitOfMeasure : " kWh " ) , type : . line ( ) )
2727 chartView. cartesianPlane. yAxisPosition = . right
28- chartView. config = FLChartConfig ( granularityY : 30 )
29-
28+ chartView. config. dashedLines . color = . red
29+
3030 let barChartData = FLChartData ( title: " Consumptions " ,
3131 data: monthsData,
3232 legendKeys: [
33- Key ( key: " F1 " , yThresholds: [ 40 : . red,
34- 56 : . blue,
35- 84 : . green,
36- 100 : . orange] ,
37- data: monthsData) ,
38- Key ( key: " F2 " , xColors: [ . red,
39- . blue,
40- . green,
41- . orange] ) ] ,
33+ Key ( key: " 1 " , color: . red) ,
34+ Key ( key: " 2 " , color: . blue) ,
35+ Key ( key: " 3 " , color: . green)
36+
37+
38+ // Key(key: "F1", yThresholds: [40 : .red,
39+ // 56 : .blue,
40+ // 84 : .green,
41+ // 100 : .orange],
42+ // data: monthsData),
43+ // Key(key: "F2", xColors: [.red,
44+ // .blue,
45+ // .green,
46+ // .orange]),
47+ // Key(key: "F3", xColors: [.red,
48+ // .blue,
49+ // .green,
50+ // .orange])
51+ ] ,
4252 unitOfMeasure: " kWh " )
4353 barChartData. xAxisUnitOfMeasure = " months "
4454 barChartData. yAxisFormatter = . decimal( 2 )
@@ -70,12 +80,13 @@ class ViewController: UIViewController {
7080 radarChart. showXAxisLabels = true
7181 radarChart. showYAxisLabels = true
7282
73- let lineChart = FLChart ( data: barChartData, type: . line( ) )
74- // lineChart.cartesianPlane.showUnitsOfMeasure = false
75-
83+ let lineChart = FLChart ( data: barChartData, type: . bar( bar: FLHorizontalMultipleValuesChartBar . self, config: FLBarConfig ( radius: . capsule, width: 30 , spacing: 15 ) ) )
84+ lineChart. showAverageLine = true
85+ lineChart. config = FLChartConfig ( granularityY: 20 )
86+
7687 let card = FLCard ( chart: lineChart, style: . rounded)
77- card. showAverage = true
78- card. showLegend = true
88+ card. showAverage = false
89+ card. showLegend = false
7990
8091 view. addSubview ( card)
8192 card. translatesAutoresizingMaskIntoConstraints = false
@@ -100,18 +111,18 @@ class ViewController: UIViewController {
100111extension ViewController {
101112
102113 var monthsData : [ MultiPlotable ] {
103- [ MultiPlotable ( name: " jan " , values: [ 30 , 24 ] ) ,
104- MultiPlotable ( name: " feb " , values: [ 55 , 44 ] ) ,
105- MultiPlotable ( name: " mar " , values: [ 70 , 15 ] ) ,
106- MultiPlotable ( name: " apr " , values: [ 45 , 68 ] ) ,
107- MultiPlotable ( name: " may " , values: [ 85 , 46 ] ) ,
108- MultiPlotable ( name: " jun " , values: [ 46 , 73 ] ) ,
109- MultiPlotable ( name: " jul " , values: [ 75 , 46 ] ) ,
110- MultiPlotable ( name: " aug " , values: [ 10 , 24 ] ) ,
111- MultiPlotable ( name: " set " , values: [ 60 , 74 ] ) ,
112- MultiPlotable ( name: " oct " , values: [ 75 , 72 ] ) ,
113- MultiPlotable ( name: " nov " , values: [ 85 , 105 ] ) ,
114- MultiPlotable ( name: " dec " , values: [ 55 , 66 ] ) ]
114+ [ MultiPlotable ( name: " jan " , values: [ 30 , 24 , 53 ] ) ,
115+ MultiPlotable ( name: " feb " , values: [ 55 , 44 , 24 ] ) ,
116+ MultiPlotable ( name: " mar " , values: [ 70 , 15 , 44 ] ) ,
117+ MultiPlotable ( name: " apr " , values: [ 45 , 68 , 34 ] ) ,
118+ MultiPlotable ( name: " may " , values: [ 85 , 46 , 12 ] ) ,
119+ MultiPlotable ( name: " jun " , values: [ 46 , 73 , 32 ] ) ,
120+ MultiPlotable ( name: " jul " , values: [ 75 , 46 , 53 ] ) ,
121+ MultiPlotable ( name: " aug " , values: [ 10 , 24 , 24 ] ) ,
122+ MultiPlotable ( name: " set " , values: [ 60 , 74 , 44 ] ) ,
123+ MultiPlotable ( name: " oct " , values: [ 75 , 72 , 34 ] ) ,
124+ MultiPlotable ( name: " nov " , values: [ 85 , 10 , 15 ] ) ,
125+ MultiPlotable ( name: " dec " , values: [ 55 , 66 , 32 ] ) ]
115126 }
116127
117128 var scatterData : [ ScatterPlotable ] {
0 commit comments