Dear Telerik Team,
In my App, I am preparing the charts & showing it in a tableview cell (can look at the images in the attachment).
for Trend charts i would like to show a track ball, here i am sharing the code of mine(I have tried the code from some document of telerik but no luck).
any help on this will be appreciated.
(CODE:)
if title == "trend"{
var arr1: Array<Array<String>> = seriess
let chart = TKChart(frame: CGRectInset(CGRectMake(0,3, screenBounds.size.width, 300), 5, 0))
for var j = 0; j < arr1.count; j++ {
var arr : Array<String> = arr1[j]
var ActulaData = [TKChartDataPoint]()
for var i = 0; i < arr.count; i++ {
var actual = ""
actual = arr[i]
actual = actual.stringByReplacingOccurrencesOfString(",", withString: "")
var act: Int? = (actual as NSString).integerValue //actual.toInt()
ActulaData.append(TKChartDataPoint(x: categry[i], y: act))
}
let seriesForExpenses = TKChartLineSeries(items: ActulaData)
seriesForExpenses.title = series_titles[j]
chart.addSeries(seriesForExpenses)
chart.backgroundColor = UIColor.whiteColor()
}
chart.legend.hidden = false
//trackball
let color = UIColor.redColor()
let size = CGSizeMake(20, 20)
let shape = TKPredefinedShape(type: TKShapeType.Rhombus, andSize: size)
chart.trackball.line.style.verticalLineStroke = TKStroke(color: color, width: 2.0)
chart.trackball.line.style.pointShapeFill = TKSolidFill(color: color)
chart.trackball.line.style.pointShape = shape
chart.delegate = self
let gridStyle = chart.gridStyle
gridStyle.horizontalLineStroke = TKStroke(color: UIColor.lightGrayColor())
gridStyle.horizontalLineAlternateStroke = TKStroke(color:UIColor.lightGrayColor())
gridStyle.horizontalFill = TKSolidFill(color: UIColor.whiteColor())
gridStyle.horizontalAlternateFill = TKSolidFill(color: UIColor.whiteColor())
gridStyle.horizontalLinesHidden = false
gridStyle.verticalLinesHidden = true
Cell4! .addSubview(chart)
chart.xAxis?.style.labelStyle.font = UIFont.systemFontOfSize(8)
chart.yAxis?.style.labelStyle.font = UIFont.systemFontOfSize(8)
chart.yAxis?.style.lineHidden = false
chart.yAxis?.style.lineStroke.width = 2
chart.yAxis?.title = axis
chart.yAxis?.style.titleStyle.rotationAngle = CGFloat(-M_PI_2)
chart.title.hidden = false
chart.title.text = chartTitle
chart.title.textColor = UIColor .blackColor()
chart.title.textAlignment = NSTextAlignment.Center
chart.update()
Cell4!.backgroundColor = UIColor(red: 248/255, green: 248/255, blue: 255/255, alpha: 1.0)
return Cell4!
}
func chart(chart: TKChart, trackballDidTrackSelection selection: [AnyObject]) {
if selection.count > 0 {
let value: AnyObject = (selection[0] as! TKChartSelectionInfo).dataPoint!.dataXValue
let str = "Pos=\(value)"
chart.trackball.tooltip.text = str
}
}