X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=experimental%2Fpalette%2Fsamples.js;h=aa84c39da42da10c8d0c7e85e52996893ffafef0;hb=e41ef65aa9e87306657157c0663032e5ea9547fe;hp=2761b78cd584c7750f9f3d2e690e76ab662d1c39;hpb=3dcf1f1f6ade5ff7465ebcffc52c1dd93f9d0b72;p=dygraphs.git diff --git a/experimental/palette/samples.js b/experimental/palette/samples.js index 2761b78..aa84c39 100644 --- a/experimental/palette/samples.js +++ b/experimental/palette/samples.js @@ -26,8 +26,11 @@ "use strict"; -var Samples = { - interestingShapes: { +var Samples = {}; +Samples.data = [ + { + id: "interestingShapes", + title: "Interesting Shapes", data: function() { var zp = function(x) { if (x < 10) return "0"+x; else return x; }; var r = "date,parabola,line,another line,sine wave\n"; @@ -58,26 +61,34 @@ var Samples = { ylabel: 'Count', axisLineColor: 'white', drawXGrid: false, - pointClickCallback: function() { alert("p-click!"); }, + +// This indentation is intentional; do not fix. + pointClickCallback: function() { + alert("p-click!"); +} } }, - sparse: { - data: [ - [ new Date("2009/12/01"), 10, 10, 10], - [ new Date("2009/12/02"), 15, 11, 12], - [ new Date("2009/12/03"), null, null, 12], - [ new Date("2009/12/04"), 20, 14, null], - [ new Date("2009/12/05"), 15, null, 17], - [ new Date("2009/12/06"), 18, null, null], - [ new Date("2009/12/07"), 12, 14, null] - ], - options: { - labels: ["Date", "Series1", "Series2", "Series3"] - } + { + id: "sparse", + title: "Sparse Data", + data: [ + [ new Date("2009/12/01"), 10, 10, 10], + [ new Date("2009/12/02"), 15, 11, 12], + [ new Date("2009/12/03"), null, null, 12], + [ new Date("2009/12/04"), 20, 14, null], + [ new Date("2009/12/05"), 15, null, 17], + [ new Date("2009/12/06"), 18, null, null], + [ new Date("2009/12/07"), 12, 14, null] + ], + options: { + labels: ["Date", "Series1", "Series2", "Series3"] + } }, - manyPoints: { + { + id: "manyPoints", + title: "Dense Data", data: function() { var numPoints = 1000; var numSeries = 100; @@ -106,5 +117,78 @@ var Samples = { title: 'Many Points', axisLineColor: 'white', } + }, + + { + id: "errorBars", + title: "Error Bars", + data: [ + [1, [10, 10, 100]], + [2, [15, 20, 110]], + [3, [10, 30, 100]], + [4, [15, 40, 110]], + [5, [10, 120, 100]], + [6, [15, 50, 110]], + [7, [10, 70, 100]], + [8, [15, 90, 110]], + [9, [10, 50, 100]] + ], + options: { + customBars: true, + errorBars: true + } + }, + + { + id: "perSeries", + title: "Per Series Options", + data: function() { + var zp = function(x) { if (x < 10) return "0"+x; else return x; }; + var r = "date,parabola,line,another line,sine wave,sine wave2\n"; + for (var i=1; i<=31; i++) { + r += "200610" + zp(i); + r += "," + 10*(i*(31-i)); + r += "," + 10*(8*i); + r += "," + 10*(250 - 8*i); + r += "," + 10*(125 + 125 * Math.sin(0.3*i)); + r += "," + 10*(125 + 125 * Math.sin(0.3*i+Math.PI)); + r += "\n"; + } + return r; + }, + options: { + strokeWidth: 2, + series : { + 'parabola': { + strokeWidth: 0.0, + drawPoints: true, + pointSize: 4, + highlightCircleSize: 6 + }, + 'line': { + strokeWidth: 1.0, + drawPoints: true, + pointSize: 1.5 + }, + 'sine wave': { + strokeWidth: 3, + highlightCircleSize: 10 + }, + 'sine wave2': { + strokePattern: [10, 2, 5, 2], + strokeWidth: 2, + highlightCircleSize: 3 + } + } + } + } +]; + +Samples.indexOf = function(id) { + for (var idx in Samples.data) { + if (Samples.data[idx].id == id) { + return idx; + } } + return null; }