Published
Edited
Sep 24, 2020
Insert cell
md`# NetV@1 TestDoc: Initialization>link`
Insert cell
toc()
Insert cell
import { NetV, refresh, getPixelColor, error_color, success_color, warning_color, hex2rgba, rgba2hex, isHexColorSame, isNumberSame, generateAutoTestCaseDescription, generateE2ETestCaseDescription, detectZoom, isStringSameIgnoreQuotesCase, isSameForColorCompare } from "@jackieanxis/netv-js-v1-test-document"
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
md`## Default Link StrokeWidth`
Insert cell
md`${generateE2ETestCaseDescription(default_link_stroke_width_10)}`
Insert cell
default_link_stroke_width_10['container']
Insert cell
Insert cell
md`${generateE2ETestCaseDescription(default_link_stroke_width_0)}`
Insert cell
default_link_stroke_width_0['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_stroke_width_negative)}`
Insert cell
default_link_stroke_width_negative['container']
Insert cell
Insert cell
md`${ generateAutoTestCaseDescription(default_link_stroke_width_NaN) }`
Insert cell
default_link_stroke_width_NaN['container']
Insert cell
Insert cell
md`${ generateE2ETestCaseDescription(default_link_stroke_width_unset) }`
Insert cell
default_link_stroke_width_unset['container']
Insert cell
Insert cell
md`${ generateAutoTestCaseDescription(default_link_stroke_width_undefined) }`
Insert cell
default_link_stroke_width_undefined['container']
Insert cell
Insert cell
md`${ generateAutoTestCaseDescription(default_link_stroke_width_null) }`
Insert cell
default_link_stroke_width_null['container']
Insert cell
Insert cell
md`${ generateE2ETestCaseDescription(default_link_stroke_width_string) }`
Insert cell
default_link_stroke_width_string['container']
Insert cell
Insert cell
md`## Default Link StrokeColor`
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_normal)}`
Insert cell
default_link_strokeColor_normal['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_r_negative)}`
Insert cell
default_link_strokeColor_r_negative['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_b_3)}`
Insert cell
default_link_strokeColor_b_3['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_g_undefined)}`
Insert cell
default_link_strokeColor_g_undefined['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_b_null)}`
Insert cell
default_link_strokeColor_b_null['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_a_NaN)}`
Insert cell
default_link_strokeColor_a_NaN['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_unset)}`
Insert cell
default_link_strokeColor_unset['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_undefined)}`
Insert cell
default_link_strokeColor_undefined['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_null)}`
Insert cell
default_link_strokeColor_null['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_r_unset)}`
Insert cell
default_link_strokeColor_r_unset['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_node_strokeColor_a_unset)}`
Insert cell
default_node_strokeColor_a_unset['container']
Insert cell
mutable default_node_strokeColor_a_unset = {
let log = ''
let isPassed = false
let container = DOM.element('div')
let strokeColor = { r: 0.6, b: 0.2, g: 0.4 }
let backgroundColor = {r: 0, g: 0, b: 0, a: 0}
let default_a = 0.5
let expected = rgba2hex({
a: default_a,
r: strokeColor.r * default_a,
g: strokeColor.g * default_a,
b: strokeColor.b * default_a
})
let width = 100
let height = 100
let r = 10
let strokeWidth = 10
let isSame = isSameForColorCompare
try {
refresh(container)
let netv = new NetV({
container,
width,
height,
node: {r, strokeWidth: 0},
link: {strokeColor, strokeWidth},
backgroundColor
})
netv.data({
nodes: [
{id: '0', x: width / 2, y: height / 4},
{id: '1', x: width / 2, y: height / 4 * 3}
],
links: [{source: '0', target: '1'}]
})
netv.draw()
const canvas = container.querySelector('canvas')
const actualColor = getPixelColor(canvas, width / 2, height / 2)
log = rgba2hex(actualColor)
} catch (e) {
log = e.toString()
}
return {
title: `Default Link StrokeColor.a: unset`,
container,
log,
expected,
isPassed: isSame(expected, log)
}
}
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_string)}`
Insert cell
default_link_strokeColor_string['container']
Insert cell
Insert cell
md`${generateAutoTestCaseDescription(default_link_strokeColor_r_string)}`
Insert cell
default_link_strokeColor_r_string['container']
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more