@@ -36,7 +36,7 @@ const createWindow = (type) => {
3636 } ) )
3737 const series = chart
3838 . addLineSeries ( {
39- schema : { x : { pattern : 'progressive' } , y : { pattern : null } } ,
39+ schema : { x : { pattern : 'progressive' } , y : { pattern : null } } , automaticColorIndex : 1 ,
4040 } )
4141 . setMaxSampleCount ( 100_000 )
4242 . setStrokeStyle ( ( stroke ) => stroke . setThickness ( 1 ) )
@@ -53,24 +53,37 @@ const createWindow = (type) => {
5353 container . append ( canvas )
5454 canvas . style . width = '100%'
5555 canvas . style . height = '100%'
56- const ctx = canvas . getContext ( '2d' )
5756
58- ctx . fillStyle = 'blue'
59- ctx . fillRect ( 50 , 50 , 100 , 100 )
57+ const image = new Image ( )
58+ image . crossOrigin = ''
59+ image . src = new URL ( document . head . baseURI ) . origin + new URL ( document . head . baseURI ) . pathname + 'examples/assets/0513/index.jpg'
6060
61- ctx . beginPath ( )
62- ctx . arc ( 250 , 100 , 50 , 0 , Math . PI * 2 )
63- ctx . fillStyle = 'red'
64- ctx . fill ( )
65- ctx . closePath ( )
61+ image . onload = ( ) => {
62+ const ctx = canvas . getContext ( '2d' )
63+ const rect = canvas . getBoundingClientRect ( )
64+ canvas . width = rect . width
65+ canvas . height = ( image . height / image . width ) * rect . width
66+ ctx . drawImage ( image , 0 , 0 , canvas . width , canvas . height )
67+ }
68+
69+ // const ctx = canvas.getContext('2d')
70+
71+ // ctx.fillStyle = 'blue'
72+ // ctx.fillRect(50, 50, 100, 100)
73+
74+ // ctx.beginPath()
75+ // ctx.arc(250, 100, 50, 0, Math.PI * 2)
76+ // ctx.fillStyle = 'red'
77+ // ctx.fill()
78+ // ctx.closePath()
6679
67- ctx . beginPath ( )
68- ctx . moveTo ( 25 , 100 )
69- ctx . lineTo ( 225 , 100 )
70- ctx . strokeStyle = 'green'
71- ctx . lineWidth = 5
72- ctx . stroke ( )
73- ctx . closePath ( )
80+ // ctx.beginPath()
81+ // ctx.moveTo(25, 100)
82+ // ctx.lineTo(225, 100)
83+ // ctx.strokeStyle = 'green'
84+ // ctx.lineWidth = 5
85+ // ctx.stroke()
86+ // ctx.closePath()
7487
7588 windows . push ( { type : 'other' , container } )
7689 break
@@ -121,6 +134,7 @@ windows.forEach((window) => {
121134 window . container . style . border = `solid 1px ${ isDarkTheme ? 'white' : 'black' } `
122135 window . container . style . backgroundColor = isDarkTheme ? 'rgb(40,40,40)' : 'rgb(255,255,255)'
123136} )
137+ windowsContainer . style . backgroundColor = isDarkTheme ? 'rgb(40,40,40)' : 'rgb(255,255,255)'
124138
125139// Setup initial view for demo purposes
126140windows [ windows . length - 2 ] . container . style . left = '130px'
0 commit comments