4 <meta http-equiv=
"X-UA-Compatible" content=
"IE=EmulateIE7; IE=EmulateIE9">
5 <title>Custom Circles
</title>
7 <script type=
"text/javascript" src=
"../excanvas.js"></script>
10 For production (minified) code, use:
11 <script type=
"text/javascript" src=
"dygraph-combined.js"></script>
13 <script type=
"text/javascript" src=
"../dygraph-dev.js"></script>
14 <script type=
"text/javascript" src=
"../extras/stars.js"></script>
18 <h2>Custom circles and hover circles
</h2>
20 <script type=
"text/javascript">
22 var div = document.createElement('div');
23 document.body.appendChild(div);
25 var data = 'x,A,B
\n' +
31 var g = new Dygraph(div, data, {
34 highlightCircleSize:
8,
37 drawPointCallback : Dygraph.Circles.TRIANGLE,
38 drawHighlightPointCallback : Dygraph.Circles.TRIANGLE
41 drawPointCallback : Dygraph.Circles.HEXAGON,
42 drawHighlightPointCallback : Dygraph.Circles.HEXAGON
49 var smile = function(g, series, ctx, cx, cy, color, radius) {
50 mouthlessFace(g, series, ctx, cx, cy, color, radius);
52 ctx.fillStyle =
"#000000";
54 ctx.arc(cx, cy, radius -
2,
.3, Math.PI -
.3, false);
58 var frown = function(g, series, ctx, cx, cy, color, radius) {
59 mouthlessFace(g, series, ctx, cx, cy, color, radius);
62 ctx.fillStyle =
"#000000";
64 ctx.arc(cx, cy + radius, radius -
2, Math.PI +
.3, -
.3, false);
68 var mouthlessFace = function(g, series, ctx, cx, cy, color, radius) {
70 ctx.strokeStyle =
"#000000";
71 ctx.fillStyle =
"#FFFF00";
73 ctx.arc(cx, cy, radius, Math.PI *
2, false);
78 ctx.fillStyle =
"#000000";
80 ctx.arc(cx - (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
86 ctx.arc(cx + (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
92 var makeGraph = function(title, yFunc, extraOpts) {
99 var addShape = function(name, pointFn, highlightPointFn) {
102 drawPointCallback: pointFn,
103 drawHighlightPointCallback: highlightPointFn
107 for (var shape in Dygraph.Circles) {
108 if (!Dygraph.Circles.hasOwnProperty(shape)) continue;
109 var fn = Dygraph.Circles[shape];
110 if (typeof fn !== 'function') continue;
111 addShape(shape.toLowerCase(), fn, fn);
113 addShape('custom', frown, smile);
115 for (var key in extraOpts) {
116 if (extraOpts.hasOwnProperty(key)) {
117 opts[key] = extraOpts[key];
121 var header = document.createElement('h3');
122 header.appendChild(document.createTextNode(title));
123 document.body.appendChild(header);
125 var div = document.createElement('div');
126 document.body.appendChild(div);
131 var r =
"xval," + shapes.join(',') +
"\n";
132 var n = shapes.length;
133 for (var i=
1; i<=
20; i++) {
135 for (var j =
0; j < n; j++) {
136 r +=
"," + yFunc(i, j, n);
145 "Gallery of predefined shapes, adding a custom shape:",
147 return x /
3 + c *
10;
149 highlightCircleSize :
8
152 "With interactive per-series highlighting:",
154 return Math.sin(x * c / n);
156 strokeBorderWidth:
2,
157 highlightSeriesOpts: {
159 highlightCircleSize:
10,