本文整理匯總了TypeScript中models/sources/columnar_data_source.ColumnarDataSource類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ColumnarDataSource類的具體用法?TypeScript ColumnarDataSource怎麽用?TypeScript ColumnarDataSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ColumnarDataSource類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: get_value
export function get_value(name: string, data_source: ColumnarDataSource, i: Index, special_vars: Vars) {
if (name[0] == "$") {
if (name.substring(1) in special_vars)
return special_vars[name.substring(1)]
else
throw new Error(`Unknown special variable '${name}'`)
}
const column = data_source.get_column(name)
// missing column
if (column == null)
return null
// typical (non-image) index
if (isNumber(i))
return column[i]
// image index
const data = column[i.index]
if (isTypedArray(data) || isArray(data)) {
// inspect array of arrays
if (isArray(data[0])) {
const row: any = data[i.dim2]
return row[i.dim1]
} else
return data[i.flat_index] // inspect flat array
} else
return data // inspect per-image scalar data
}
示例2: if
str = str.replace(/(^|[^@])@(?:(\$?\w+)|{([^{}]+)})(?:{([^{}]+)})?/g, (_match, prefix, name, long_name, format) => {
name = long_name != null ? long_name : name
let value: any
if (name[0] == "$")
value = special_vars[name.substring(1)]
else {
const column = data_source.get_column(name)
if (column != null)
value = column[i]
}
let replacement = null
if (value == null)
replacement = "???"
else {
// 'safe' format, just return the value as is
if (format == 'safe')
return `${prefix}${value}`
else if (format != null) {
// see if the field has an entry in the formatters dict
if (formatters != null && name in formatters) {
const formatter = formatters[name]
switch (formatter) {
case "numeral":
replacement = Numbro.format(value, format)
break
case "datetime":
replacement = tz(value, format)
break
case "printf":
replacement = sprintf(format, value)
break
default:
throw new Error(`Unknown tooltip field formatter type '${formatter}'`)
}
// if not assume the format string is Numbro
} else
replacement = Numbro.format(value, format)
// no format supplied, just use a basic default numeric format
} else
replacement = _format_number(value)
}
return `${prefix}${escape(replacement)}`
})
示例3: inspect
inspect(renderer_view: RendererView, geometry: Geometry): boolean {
let did_hit = false
if (renderer_view.model.type == 'GlyphRenderer') {
const hit_test_result = renderer_view.hit_test(geometry)
did_hit = !hit_test_result.is_empty()
const inspection = this.get_or_create_inspector(renderer_view.model)
inspection.update(hit_test_result, true, false)
this.source.setv({inspected: inspection}, {silent: true})
this.source.inspect.emit([renderer_view, {geometry: geometry}])
} else {
if (renderer_view.model instanceof GraphRenderer) {
const hit_test_result = renderer_view.model.inspection_policy.hit_test(geometry, renderer_view)
did_hit = did_hit || renderer_view.model.inspection_policy.do_inspection(hit_test_result, geometry, renderer_view, false, false)
}
}
return did_hit
}