有没有办法在 SciChart IOs 折线图上滚动时显示的工具提示中只显示一个值?有很多关于如何在 android 和 WPF 中执行此操作的示例,但不适用于 IO。
user8097608
问问题
232 次
1 回答
1
您将需要执行以下操作。首先,一个自定义的可渲染系列,例如,如果您使用 LineRenderableSeries,则必须创建一个从 SCIFastLineRenderableSeries 派生的新类并覆盖 toSeriesInfo: 方法,如下所示
class CustomLineSeries : SCIFastLineRenderableSeries {
override func toSeriesInfo(withHitTest info: SCIHitTestInfo) -> SCISeriesInfo! {
return CustomSeriesInfo(series: self, hitTest: info)
}
}
在接下来的步骤中,我们创建了一个 CustomSeriesInfo 类,我们将在我们刚刚创建的自定义可渲染系列类中使用该类:
class CustomSeriesInfo : SCIXySeriesInfo {
override func createDataSeriesView() -> SCITooltipDataView! {
let view : CustomSeriesDataView = CustomSeriesDataView.createInstance() as! CustomSeriesDataView
view.setData(self)
return view;
}
}
最后,我们创建一个自定义系列数据视图 - 一个显示我们想要的实际视图:
class CustomSeriesDataView : SCIXySeriesDataView {
static override func createInstance() -> SCITooltipDataView! {
let view : CustomSeriesDataView = (Bundle.main.loadNibNamed("CustomSeriesDataView", owner: nil, options: nil)![0] as? CustomSeriesDataView)!
view.translatesAutoresizingMaskIntoConstraints = false
return view
}
override func setData(_ data: SCISeriesInfo!) {
let series : SCIRenderableSeriesProtocol = data.renderableSeries()
var xFormattedValue : String? = data.fortmatterdValue(fromSeriesInfo: data.xValue(), for: series.dataSeries.xType())
let xAxis = series.xAxis
if (xFormattedValue == nil) {
xFormattedValue = xAxis?.formatCursorText(data.xValue())
}
self.dataLabel.text = ""
self.nameLabel.text = String(format: "X: %@", xFormattedValue!)
self.invalidateIntrinsicContentSize()
}
}
注意:您必须创建一个实际的 View 并使用 CustomSeriesDataView 作为它的主类;并绑定网点。
于 2017-10-10T10:42:56.680 回答