Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplement Image Icon's in v7 & FontBook class #80

Merged
merged 48 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
be5e058
add ImageIcon to icon class
mggower Nov 2, 2023
c733b63
fix reference bug when updating label background size
mggower Nov 2, 2023
642982a
include image icon in label example
mggower Nov 2, 2023
5291690
generate FontBook class with static methods for installing bitmap fonts
mggower Nov 2, 2023
e6e8b9f
implement FontBook class to manage font loading
mggower Nov 3, 2023
f2538de
use consistent variable names in Icon class
mggower Nov 6, 2023
7383173
use FontFaceObserver to load browser fonts
mggower Nov 7, 2023
ad2ec78
use PIXI.Assets to load image icons
mggower Nov 7, 2023
36c0b98
fix large render perf bug with promises
mggower Nov 8, 2023
94fc274
cache image icon promises
mggower Nov 8, 2023
4c6ebb1
cleanup assets PR
mggower Nov 8, 2023
616906c
consider label bounds when culling offscreen nodes
mggower Nov 6, 2023
7d4dbe4
bugfix: reset transformed property on label
mggower Nov 6, 2023
87766f1
adress pr feedback
mggower Nov 17, 2023
cf58e98
resolve perf issues with `getBounds` from label
mggower Nov 17, 2023
921a732
improve issues with BitmapText placement
mggower Nov 17, 2023
56bc075
Bump msgpackr from 1.9.9 to 1.10.1
dependabot[bot] Dec 28, 2023
b98942f
Bump vite from 4.5.0 to 4.5.2
dependabot[bot] Jan 20, 2024
bd44cfe
add async util
jameslaneconkling Feb 5, 2024
a11a6b7
add in FontLoader and AssetLoader to reduce promises
mggower Feb 5, 2024
e066662
AssetLoader to manage all asset loading
mggower Feb 6, 2024
8929bcc
implement FontLoader for node labels
mggower Feb 6, 2024
cb1b30d
implement asset loading on node icon
mggower Feb 6, 2024
a038c64
implement edge labels
mggower Feb 6, 2024
fb086f0
remove loaders from FontBook
mggower Feb 6, 2024
2c9db14
Merge branch 'feature/assets' into feature/label-culling
mggower Feb 6, 2024
96093f1
perf improvements on label culling
mggower Feb 6, 2024
0f8c540
remove label bounds utils
mggower Feb 6, 2024
52c95b8
clean up label/background methods+utils
mggower Feb 7, 2024
ca17d3d
cleanup node methods
mggower Feb 7, 2024
b90730b
Merge pull request #83 from sayari-analytics/feature/label-culling
jameslaneconkling Feb 12, 2024
06df657
types/ and utils/ directory to organize export entry
mggower Feb 8, 2024
9c8fe9e
update object types
mggower Feb 8, 2024
55d814e
init: TextTexture + Text object to replace Label
mggower Feb 8, 2024
0010ec3
replace Label class with Text class to be used for other use cases
mggower Feb 9, 2024
8a253d0
manage font loading in `Text`
mggower Feb 9, 2024
be3a5d7
load assets in Icon class
mggower Feb 9, 2024
909fbfe
cancel method in `Text` to unsubscribe
mggower Feb 9, 2024
fcc0949
align TextIcon with TextStyle
mggower Feb 9, 2024
cc24ebf
standardize interface for textures with `Texture` type
mggower Feb 12, 2024
47d3fa6
reduce list of generic font families
mggower Feb 12, 2024
97c8d56
include loading state and enable `cancel` method on loaders
mggower Feb 12, 2024
dd327fe
fix return type on `image` method
mggower Feb 12, 2024
3c8cab0
Merge pull request #97 from sayari-analytics/feature/text
mggower Feb 12, 2024
2adc49e
resolve conflicts
mggower Feb 12, 2024
cd1067f
standardize render object lifecycle and mounting patterns
mggower Feb 12, 2024
ad0ba22
address Text perf rendering issues
mggower Feb 12, 2024
86576a6
sync applyLabel in node/edge renderers
mggower Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/assets/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const person = `data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV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wvZz4KICAgIDwvZz4KPC9zdmc+`
Binary file added examples/assets/person.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions examples/native/src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
@import '../../reset';
@import url("https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap");

@font-face {
font-family: Roboto;
font-weight: 400;
font-style: normal;
font-stretch: normal;
font-display: swap;
}

#examples {
display: flex;
Expand Down
23 changes: 15 additions & 8 deletions examples/native/src/labels/index.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import * as Renderer from '@trellis/renderers/webgl'
import * as Graph from '@trellis/index'
import * as Collide from '@trellis/layout/collide'
import { person } from '../../../assets/icons'

const GREEN = '#91AD49'
const GREEN_LIGHT = '#C6D336'
const DARK_GREEN = '#607330'

const IMAGE_ICON: Graph.ImageIcon = {
type: 'imageIcon',
url: person,
scale: 0.66
}

const TEXT_ICON: Graph.TextIcon = {
type: 'textIcon',
family: 'sans-serif',
fontFamily: 'sans-serif',
fontWeight: '400',
fontSize: 14,
color: '#fff',
weight: '400',
text: '!',
size: 14
text: '!'
}

const NODE_STYLE: Graph.NodeStyle = {
color: GREEN,
icon: TEXT_ICON,
icon: IMAGE_ICON,
stroke: [{ width: 2, color: GREEN_LIGHT }],
label: {
position: 'right',
fontName: 'NodeLabel',
fontFamily: 'Arial, sans-serif',
fontFamily: 'Roboto',
background: { color: GREEN_LIGHT },
margin: 4
}
Expand All @@ -35,7 +42,7 @@ const NODE_HOVER_STYLE: Graph.NodeStyle = {
label: {
position: 'right',
fontName: 'NodeLabelHover',
fontFamily: 'Arial, sans-serif',
fontFamily: 'Roboto',
background: { color: DARK_GREEN },
color: '#FFF',
margin: 4
Expand All @@ -62,7 +69,7 @@ const collide = Collide.Layout()
const edges: Graph.Edge[] = []
let nodes = data.map<Graph.Node>((label, index) => ({
radius: 10,
label: index % 2 === 0 ? label + ' 北京' : label,
label,
id: `${index}-${label}`,
style: NODE_STYLE
}))
Expand Down
13 changes: 5 additions & 8 deletions examples/native/src/perf/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,25 @@ const sampleCoordinatePlane = function* (count: number, step: number, sample: nu
const PURPLE = '#7A5DC5'
const LIGHT_PURPLE = '#CAD'
const ARIAL_PINK = 'ArialPink'
const TEXT_ICON: Graph.TextIcon = { type: 'textIcon', text: 'T', fontFamily: 'sans-serif', fontSize: 14, color: '#fff', fontWeight: '400' }

const NODE_STYLE: Graph.NodeStyle = {
color: PURPLE,
stroke: [{ width: 2, color: LIGHT_PURPLE }],
icon: { type: 'textIcon', text: 'T', family: 'sans-serif', size: 14, color: '#fff', weight: '400' },
icon: TEXT_ICON,
label: {
position: 'top',
fontName: ARIAL_PINK,
fontFamily: ['Arial', 'sans-serif'],
margin: 2,
background: {
color: '#f66',
opacity: 0.5
}
fontFamily: 'Roboto',
margin: 2
}
}

const NODE_HOVER_STYLE: Graph.NodeStyle = {
color: '#f66',
stroke: [{ width: 2, color: '#fcc' }],
label: { position: 'bottom', color: '#fcc' },
icon: { type: 'textIcon', text: 'L', family: 'sans-serif', size: 14, color: '#fff', weight: '400' }
icon: TEXT_ICON
}

const EDGE_STYLE: Graph.EdgeStyle = {
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"d3-force": "^3.0.0",
"d3-hierarchy": "^3.1.2",
"d3-interpolate": "^3.0.1",
"fontfaceobserver": "^2.3.0",
"pixi.js": "^7.3.2",
"stats.js": "^0.17.0"
},
Expand All @@ -54,6 +55,7 @@
"@types/d3-interpolate": "^3.0.3",
"@types/d3-scale": "^4.0.6",
"@types/d3-scale-chromatic": "^3.0.1",
"@types/fontfaceobserver": "^2.1.3",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@types/stats.js": "^0.17.2",
Expand All @@ -75,13 +77,23 @@
"vite": "^4.5.0",
"vitest": "^0.34.6"
},
"keywords": ["graph", "network", "infovis", "visualization", "react", "webgl"],
"keywords": [
"graph",
"network",
"infovis",
"visualization",
"react",
"webgl"
],
"peerDependencies": {
"react": ">=16.0"
},
"repository": {
"type": "git",
"url": "https://github.com/sayari-analytics/trellis.git"
},
"workspaces": ["examples/native", "examples/react"]
"workspaces": [
"examples/native",
"examples/react"
]
}
30 changes: 7 additions & 23 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TWO_PI } from './renderers/webgl/utils'
import type { NodeIcon } from './renderers/webgl/objects/icon'
import type { LabelStyle } from './renderers/webgl/objects/label'
import type { Stroke } from './types'

Expand Down Expand Up @@ -26,36 +27,17 @@ export type Edge = {
style?: EdgeStyle
}

export type TextIcon = {
type: 'textIcon'
family: string
text: string
color: string
size: number
weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
offsetX?: number
offsetY?: number
}

export type ImageIcon = {
type: 'imageIcon'
url: string
scale?: number
offsetX?: number
offsetY?: number
}

export type NodeStyle = {
color?: string
icon?: TextIcon | ImageIcon
icon?: NodeIcon
stroke?: Stroke[]
badge?: {
position: number
radius: number
color: string
stroke?: string
strokeWidth?: number
icon?: TextIcon | ImageIcon
icon?: NodeIcon
}[]
label?: LabelStyle
}
Expand Down Expand Up @@ -380,5 +362,7 @@ export const angle = (x0: number, y0: number, x1: number, y1: number) => {
}

// exports
export type { Stroke } from './types'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition, FontWeight, TextAlign } from './renderers/webgl/objects/label'
export type { Stroke, NodeIcon }
export type { FontWeight, TextAlign } from './types'
export type { LabelStyle, LabelBackgroundStyle, LabelPosition } from './renderers/webgl/objects/label'
export type { TextIcon, ImageIcon } from './renderers/webgl/textures/icons'
3 changes: 2 additions & 1 deletion src/renderers/webgl/edge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MIN_EDGES_ZOOM, MIN_INTERACTION_ZOOM, Renderer } from '.'
import { type Renderer } from '.'
import { MIN_EDGES_ZOOM, MIN_INTERACTION_ZOOM } from './utils'
import { movePoint } from './utils'
import { NodeRenderer } from './node'
import * as Graph from '../..'
Expand Down
16 changes: 5 additions & 11 deletions src/renderers/webgl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { NodeRenderer } from './node'
import { EdgeRenderer } from './edge'
import { ArrowTexture } from './textures/arrow'
import { CircleTexture } from './textures/circle'
import { Font } from './textures/font'
import { interpolate } from '../../utils'
import { logUnknownEdgeError } from './utils'
import { ObjectManager } from './objectManager'
import { TextIconTexture } from './textures/textIcon'
import { TextIconTexture, ImageIconTexture } from './textures/icons'
import { FontBook } from './textures/font'

export type Keys = { altKey?: boolean; ctrlKey?: boolean; metaKey?: boolean; shiftKey?: boolean }
export type MousePosition = { x: number; y: number; clientX: number; clientY: number }
Expand Down Expand Up @@ -99,14 +99,6 @@ export const defaultOptions = {
dragInertia: 0.88
}

// TODO - make configurable
export const MIN_LABEL_ZOOM = 0.25
jameslaneconkling marked this conversation as resolved.
Show resolved Hide resolved
export const MIN_NODE_STROKE_ZOOM = 0.3
export const MIN_NODE_ICON_ZOOM = 0.3
export const MIN_INTERACTION_ZOOM = 0.15
export const MIN_EDGES_ZOOM = 0.1
export const MIN_ZOOM = 3

export class Renderer {
width: number
height: number
Expand Down Expand Up @@ -140,7 +132,6 @@ export class Renderer {
edgeArrowObjectManager = new ObjectManager(1000)
labelObjectManager = new ObjectManager(2000)
interactionObjectManager = new ObjectManager(2000)
font = new Font()
eventSystem: EventSystem
nodes: Graph.Node[] = []
nodeRenderersById: Record<string, NodeRenderer> = {}
Expand All @@ -154,6 +145,8 @@ export class Renderer {
circle: CircleTexture
arrow: ArrowTexture
textIcon: TextIconTexture
imageIcon: ImageIconTexture
fontBook = new FontBook() // TODO -> make configurable
draggedNode?: NodeRenderer
hoveredNode?: NodeRenderer

Expand Down Expand Up @@ -232,6 +225,7 @@ export class Renderer {
this.circle = new CircleTexture(this)
this.arrow = new ArrowTexture(this)
this.textIcon = new TextIconTexture(this)
this.imageIcon = new ImageIconTexture()
this.eventSystem = new EventSystem(this.app.renderer)
this.eventSystem.domElement = view
this.root.eventMode = 'static' // 'passive' // TODO - add viewport events to interactionContainer
Expand Down
Loading
Loading