Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
flot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HS-public
flot
Commits
ec99d31c
Commit
ec99d31c
authored
Jul 21, 2012
by
David Schnur
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #52 from olivierguerriat/master
Basic retina display support
parents
3e7a177a
179d2e1d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
8 deletions
+36
-8
jquery.flot.js
jquery.flot.js
+36
-8
No files found.
jquery.flot.js
View file @
ec99d31c
...
@@ -148,6 +148,7 @@
...
@@ -148,6 +148,7 @@
overlay
=
null
,
// canvas for interactive stuff on top of plot
overlay
=
null
,
// canvas for interactive stuff on top of plot
eventHolder
=
null
,
// jQuery object that events should be bound to
eventHolder
=
null
,
// jQuery object that events should be bound to
ctx
=
null
,
octx
=
null
,
ctx
=
null
,
octx
=
null
,
canvasBackingScale
,
xaxes
=
[],
yaxes
=
[],
xaxes
=
[],
yaxes
=
[],
plotOffset
=
{
left
:
0
,
right
:
0
,
top
:
0
,
bottom
:
0
},
plotOffset
=
{
left
:
0
,
right
:
0
,
top
:
0
,
bottom
:
0
},
canvasWidth
=
0
,
canvasHeight
=
0
,
canvasWidth
=
0
,
canvasHeight
=
0
,
...
@@ -715,11 +716,25 @@
...
@@ -715,11 +716,25 @@
});
});
}
}
// Retina display support
function
backingScale
(
cctx
)
{
if
(
window
.
devicePixelRatio
>
1
&&
(
cctx
.
webkitBackingStorePixelRatio
===
undefined
||
cctx
.
webkitBackingStorePixelRatio
<
2
))
{
return
window
.
devicePixelRatio
;
}
return
1
;
}
function
makeCanvas
(
skipPositioning
,
cls
)
{
function
makeCanvas
(
skipPositioning
,
cls
)
{
var
c
=
document
.
createElement
(
'canvas'
);
var
c
=
document
.
createElement
(
'canvas'
);
c
.
className
=
cls
;
c
.
className
=
cls
;
c
.
width
=
canvasWidth
;
c
.
height
=
canvasHeight
;
var
cctx
=
c
.
getContext
(
"2d"
);
canvasBackingScale
=
backingScale
(
cctx
);
// Retina display support
c
.
width
=
canvasBackingScale
*
canvasWidth
;
c
.
height
=
canvasBackingScale
*
canvasHeight
;
c
.
style
.
width
=
canvasWidth
+
"px"
;
c
.
style
.
height
=
canvasHeight
+
"px"
;
if
(
!
skipPositioning
)
if
(
!
skipPositioning
)
$
(
c
).
css
({
position
:
'absolute'
,
left
:
0
,
top
:
0
});
$
(
c
).
css
({
position
:
'absolute'
,
left
:
0
,
top
:
0
});
...
@@ -730,7 +745,10 @@
...
@@ -730,7 +745,10 @@
c
=
window
.
G_vmlCanvasManager
.
initElement
(
c
);
c
=
window
.
G_vmlCanvasManager
.
initElement
(
c
);
// used for resetting in case we get replotted
// used for resetting in case we get replotted
c
.
getContext
(
"2d"
).
save
();
cctx
.
save
();
// Retina display support
cctx
.
scale
(
canvasBackingScale
,
canvasBackingScale
);
return
c
;
return
c
;
}
}
...
@@ -744,21 +762,31 @@
...
@@ -744,21 +762,31 @@
}
}
function
resizeCanvas
(
c
)
{
function
resizeCanvas
(
c
)
{
var
cctx
=
c
.
getContext
(
"2d"
);
canvasBackingScale
=
backingScale
(
cctx
);
// Retina display support
// resizing should reset the state (excanvas seems to be
// resizing should reset the state (excanvas seems to be
// buggy though)
// buggy though)
if
(
c
.
width
!=
canvasWidth
)
if
(
c
.
style
.
width
!=
canvasWidth
)
{
c
.
width
=
canvasWidth
;
c
.
width
=
canvasBackingScale
*
canvasWidth
;
c
.
style
.
width
=
canvasWidth
+
"px"
;
}
if
(
c
.
height
!=
canvasHeight
)
if
(
c
.
style
.
height
!=
canvasHeight
)
{
c
.
height
=
canvasHeight
;
c
.
height
=
canvasBackingScale
*
canvasHeight
;
c
.
style
.
height
=
canvasHeight
+
"px"
;
}
// so try to get back to the initial state (even if it's
// so try to get back to the initial state (even if it's
// gone now, this should be safe according to the spec)
// gone now, this should be safe according to the spec)
var
cctx
=
c
.
getContext
(
"2d"
);
cctx
.
restore
();
cctx
.
restore
();
// and save again
// and save again
cctx
.
save
();
cctx
.
save
();
// Retina display support
cctx
.
scale
(
canvasBackingScale
,
canvasBackingScale
);
}
}
function
setupCanvases
()
{
function
setupCanvases
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment