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>
17 <h2>Custom circles and hover circles
</h2>
19 <script type=
"text/javascript">
21 var div = document.createElement('div');
22 document.body.appendChild(div);
24 var data = 'x,A,B
\n' +
30 var g = new Dygraph(div, data, {
33 highlightCircleSize:
8,
36 drawPointCallback : Dygraph.Circles.TRIANGLE,
37 drawHighlightPointCallback : Dygraph.Circles.TRIANGLE
40 drawPointCallback : Dygraph.Circles.HEXAGON,
41 drawHighlightPointCallback : Dygraph.Circles.HEXAGON
48 var smile = function(g, series, ctx, cx, cy, color, radius) {
49 mouthlessFace(g, series, ctx, cx, cy, color, radius);
51 ctx.fillStyle =
"#000000";
53 ctx.arc(cx, cy, radius -
2,
.3, Math.PI -
.3, false);
57 var frown = function(g, series, ctx, cx, cy, color, radius) {
58 mouthlessFace(g, series, ctx, cx, cy, color, radius);
61 ctx.fillStyle =
"#000000";
63 ctx.arc(cx, cy + radius, radius -
2, Math.PI +
.3, -
.3, false);
67 var mouthlessFace = function(g, series, ctx, cx, cy, color, radius) {
69 ctx.strokeStyle =
"#000000";
70 ctx.fillStyle =
"#FFFF00";
72 ctx.arc(cx, cy, radius, Math.PI *
2, false);
77 ctx.fillStyle =
"#000000";
79 ctx.arc(cx - (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
85 ctx.arc(cx + (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
91 var makeGraph = function(title, yFunc, extraOpts) {
98 var addShape = function(name, pointFn, highlightPointFn) {
101 drawPointCallback: pointFn,
102 drawHighlightPointCallback: highlightPointFn
106 for (var shape in Dygraph.Circles) {
107 if (!Dygraph.Circles.hasOwnProperty(shape)) continue;
108 var fn = Dygraph.Circles[shape];
109 if (typeof fn !== 'function') continue;
110 addShape(shape.toLowerCase(), fn, fn);
112 addShape('custom', frown, smile);
114 for (var key in extraOpts) {
115 if (extraOpts.hasOwnProperty(key)) {
116 opts[key] = extraOpts[key];
120 var header = document.createElement('h3');
121 header.appendChild(document.createTextNode(title));
122 document.body.appendChild(header);
124 var div = document.createElement('div');
125 document.body.appendChild(div);
130 var r =
"xval," + shapes.join(',') +
"\n";
131 var n = shapes.length;
132 for (var i=
1; i<=
20; i++) {
134 for (var j =
0; j < n; j++) {
135 r +=
"," + yFunc(i, j, n);
144 "Gallery of predefined shapes, adding a custom shape:",
146 return x /
3 + c *
10;
148 highlightCircleSize :
8
151 "With interactive per-series highlighting:",
153 return Math.sin(x * c / n);
155 strokeBorderWidth:
2,
156 highlightSeriesOpts: {
158 highlightCircleSize:
10,