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,
35 drawPointCallback : Dygraph.Circles.TRIANGLE,
36 drawHighlightPointCallback : Dygraph.Circles.TRIANGLE
39 drawPointCallback : Dygraph.Circles.HEXAGON,
40 drawHighlightPointCallback : Dygraph.Circles.HEXAGON
46 var smile = function(g, series, ctx, cx, cy, color, radius) {
47 mouthlessFace(g, series, ctx, cx, cy, color, radius);
49 ctx.fillStyle =
"#000000";
51 ctx.arc(cx, cy, radius -
2,
.3, Math.PI -
.3, false);
55 var frown = function(g, series, ctx, cx, cy, color, radius) {
56 mouthlessFace(g, series, ctx, cx, cy, color, radius);
59 ctx.fillStyle =
"#000000";
61 ctx.arc(cx, cy + radius, radius -
2, Math.PI +
.3, -
.3, false);
65 var mouthlessFace = function(g, series, ctx, cx, cy, color, radius) {
67 ctx.strokeStyle =
"#000000";
68 ctx.fillStyle =
"#FFFF00";
70 ctx.arc(cx, cy, radius, Math.PI *
2, false);
75 ctx.fillStyle =
"#000000";
77 ctx.arc(cx - (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
83 ctx.arc(cx + (radius /
3) , cy - (radius /
4),
1, Math.PI *
2, false);
89 var makeGraph = function(title, yFunc, extraOpts) {
96 var addShape = function(name, pointFn, highlightPointFn) {
99 drawPointCallback: pointFn,
100 drawHighlightPointCallback: highlightPointFn
104 for (var shape in Dygraph.Circles) {
105 if (!Dygraph.Circles.hasOwnProperty(shape)) continue;
106 var fn = Dygraph.Circles[shape];
107 if (typeof fn !== 'function') continue;
108 addShape(shape.toLowerCase(), fn, fn);
110 addShape('custom', frown, smile);
112 for (var key in extraOpts) {
113 if (extraOpts.hasOwnProperty(key)) {
114 opts[key] = extraOpts[key];
118 var header = document.createElement('h3');
119 header.appendChild(document.createTextNode(title));
120 document.body.appendChild(header);
122 var div = document.createElement('div');
123 document.body.appendChild(div);
128 var r =
"xval," + shapes.join(',') +
"\n";
129 var n = shapes.length;
130 for (var i=
1; i<=
20; i++) {
132 for (var j =
0; j < n; j++) {
133 r +=
"," + yFunc(i, j, n);
142 "Gallery of predefined shapes, adding a custom shape:",
144 return x /
3 + c *
10;
146 highlightCircleSize :
8
149 "With interactive per-series highlighting:",
151 return Math.sin(x * c / n);
153 strokeBorderWidth:
2,
154 highlightSeriesOpts: {
156 highlightCircleSize:
10,