Browse files

pull out panel utility functions as a separate file, for less duplica…

…tion
  • Loading branch information...
1 parent 8a15779 commit e025993dc415bf1c1150498af8eb434fe84b1ea0 @kbroman committed Mar 7, 2014
View
4 DESCRIPTION
@@ -1,6 +1,6 @@
Package: qtlcharts
-Version: 0.1-10
-Date: 4 Mar 2014
+Version: 0.1-11
+Date: 7 Mar 2014
Title: Interactive graphics for QTL experiments
Author: Karl W Broman <kbroman@biostat.wisc.edu>
Maintainer: Karl W Broman <kbroman@biostat.wisc.edu>
View
3 Makefile
@@ -34,7 +34,7 @@ ${PANEL_DIR}/*/test/%.js: ${PANEL_DIR}/*/test/%.coffee
#------------------------------------------------------------
# javascript of panels
-jspanels: ${LODCHART_DIR}/lodchart.js ${SCATTERPLOT_DIR}/scatterplot.js ${DOTCHART_DIR}/dotchart.js ${CICHART_DIR}/cichart.js ${CURVECHART_DIR}/curvechart.js
+jspanels: ${LODCHART_DIR}/lodchart.js ${SCATTERPLOT_DIR}/scatterplot.js ${DOTCHART_DIR}/dotchart.js ${CICHART_DIR}/cichart.js ${CURVECHART_DIR}/curvechart.js ${PANEL_DIR}/panelutil.js
${PANEL_DIR}/%.js: ${PANEL_DIR}/%.coffee
coffee ${COFFEE_ARGS} -b $^
@@ -64,6 +64,7 @@ clean:
#------------------------------------------------------------
web:
+ scp ${PANEL_DIR}/panelutil.* broman-2:public_html/D3/panels/
scp ${LODCHART_DIR}/lodchart.* broman-2:public_html/D3/panels/lodchart/
cd ${LODCHART_TESTDIR};scp *.js *.json index.html broman-2:public_html/D3/panels/lodchart/test/
scp ${SCATTERPLOT_DIR}/scatterplot.* broman-2:public_html/D3/panels/scatterplot/
View
1 R/curves_w_2scatter.R
@@ -71,6 +71,7 @@ function(curveMatrix, times, scatter1, scatter2,
link_d3(file, onefile=onefile)
link_d3tip(file, onefile=onefile)
link_colorbrewer(file, onefile=onefile)
+ link_panelutil(file, onefile=onefile)
link_panel('curvechart', file, onefile=onefile)
link_panel('scatterplot', file, onefile=onefile)
link_chart('curves_w_2scatter', file, onefile=onefile)
View
1 R/iplotPXG.R
@@ -60,6 +60,7 @@ function(cross, marker, pheno.col=1,
link_d3(file, onefile=onefile)
link_d3tip(file, onefile=onefile)
+ link_panelutil(file, onefile=onefile)
link_panel('dotchart', file, onefile=onefile)
link_chart('iplotPXG', file, onefile=onefile)
View
3 R/iplotScanone.R
@@ -101,6 +101,7 @@ function(scanoneOutput, file, onefile=FALSE, openfile=TRUE, title, legend, ...)
link_d3(file, onefile=onefile)
link_d3tip(file, onefile=onefile)
+ link_panelutil(file, onefile=onefile)
link_panel('lodchart', file, onefile=onefile)
link_chart('iplotScanone_noeff', file, onefile=onefile)
@@ -134,6 +135,7 @@ function(scanoneOutput, cross, pheno.col=1, file, onefile=FALSE, openfile=TRUE,
link_d3(file, onefile=onefile)
link_d3tip(file, onefile=onefile)
+ link_panelutil(file, onefile=onefile)
link_panel('lodchart', file, onefile=onefile)
link_panel('dotchart', file, onefile=onefile)
link_chart('iplotScanone_pxg', file, onefile=onefile)
@@ -169,6 +171,7 @@ function(scanoneOutput, cross, pheno.col=1, file, onefile=FALSE, openfile=TRUE,
link_d3(file, onefile=onefile)
link_d3tip(file, onefile=onefile)
+ link_panelutil(file, onefile=onefile)
link_panel('lodchart', file, onefile=onefile)
link_panel('cichart', file, onefile=onefile)
link_chart('iplotScanone_ci', file, onefile=onefile)
View
8 R/write_html.R
@@ -203,6 +203,14 @@ function(file, onefile=FALSE)
onefile=onefile)
}
+link_panelutil <-
+function(file, onefile=FALSE)
+{
+ jsfile <- system.file('panels', 'panelutil.js', package='qtlcharts')
+ if(file.exists(jsfile))
+ append_html_jslink(file, jsfile, onefile=onefile)
+}
+
link_panel <-
function(panel, file, onefile=FALSE)
{
View
2 inst/panels/ReadMe.md
@@ -20,6 +20,8 @@ This directory contains a set of reusable panels for
- [curvechart](inst/panels/curvechart): panel for multiple curves
(uses [ColorBrewer](http://colorbrewer2.org))
+Further utility functions are in [panelutil.coffee](panelutil.coffee).
+
#### Licenses
Licensed under the [MIT license](LICENSE). ([More information](http://en.wikipedia.org/wiki/MIT_License).)
View
8 inst/panels/cichart/cichart.coffee
@@ -273,11 +273,3 @@ cichart = () ->
# return the chart function
chart
-
-# function to determine rounding of axis labels
-formatAxis = (d, extradigits=0) ->
- d = d[1] - d[0]
- ndig = Math.floor( Math.log(d % 10) / Math.log(10) ) - extradigits
- ndig = 0 if ndig > 0
- ndig = Math.abs(ndig)
- d3.format(".#{ndig}f")
View
16 inst/panels/cichart/cichart.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var cichart, formatAxis;
+var cichart;
cichart = function() {
var axispos, chart, height, margin, nyticks, rectcolor, segcolor, segstrokewidth, segwidth, title, titlepos, vertsegcolor, width, xcatlabels, xlab, xscale, ylab, ylim, yscale, yticks;
@@ -257,17 +257,3 @@ cichart = function() {
};
return chart;
};
-
-formatAxis = function(d, extradigits) {
- var ndig;
- if (extradigits == null) {
- extradigits = 0;
- }
- d = d[1] - d[0];
- ndig = Math.floor(Math.log(d % 10) / Math.log(10)) - extradigits;
- if (ndig > 0) {
- ndig = 0;
- }
- ndig = Math.abs(ndig);
- return d3.format("." + ndig + "f");
-};
View
1 inst/panels/cichart/test/index.html
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Test of reusable CI chart</title>
+ <script type="text/javascript" src="../../panelutil.js"></script>
<script charset="utf-8" type="text/javascript" src="../../../d3/d3.min.js"></script>
<link rel=stylesheet type="text/css" href="../../../d3-tip/d3-tip.min.css">
<script type="text/javascript" src="../../../d3-tip/d3-tip.min.js"></script>
View
15 inst/panels/curvechart/curvechart.coffee
@@ -324,18 +324,3 @@ curvechart = () ->
# return the chart function
chart
-
-# function to determine rounding of axis labels
-formatAxis = (d) ->
- d = d[1] - d[0]
- ndig = Math.floor( Math.log(d % 10) / Math.log(10) )
- ndig = 0 if ndig > 0
- ndig = Math.abs(ndig)
- d3.format(".#{ndig}f")
-
-pullVarAsArray = (data, variable) ->
- v = []
- for i of data
- v = v.concat data[i][variable]
- v
-
View
22 inst/panels/curvechart/curvechart.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var curvechart, formatAxis, pullVarAsArray;
+var curvechart;
curvechart = function() {
var axispos, chart, commonX, curvesSelect, height, margin, nxticks, nyticks, rectcolor, strokecolor, strokecolorhilit, strokewidth, strokewidthhilit, title, titlepos, width, xlab, xlim, xscale, xticks, ylab, ylim, yscale, yticks;
@@ -360,23 +360,3 @@ curvechart = function() {
};
return chart;
};
-
-formatAxis = function(d) {
- var ndig;
- d = d[1] - d[0];
- ndig = Math.floor(Math.log(d % 10) / Math.log(10));
- if (ndig > 0) {
- ndig = 0;
- }
- ndig = Math.abs(ndig);
- return d3.format("." + ndig + "f");
-};
-
-pullVarAsArray = function(data, variable) {
- var i, v;
- v = [];
- for (i in data) {
- v = v.concat(data[i][variable]);
- }
- return v;
-};
View
3 inst/panels/curvechart/test/index.html
@@ -3,8 +3,9 @@
<head>
<meta charset="utf-8">
<title>Test of reusable curve plot</title>
+ <script type="text/javascript" src="../../panelutil.js"></script>
<script charset="utf-8" type="text/javascript" src="../../../d3/d3.min.js"></script>
- <script charset="utf-8" type="text/javascript" src="../../../colorbrewer/colorbrewer.js"></script>
+ <script type="text/javascript" src="../../../colorbrewer/colorbrewer.js"></script>
<link rel=stylesheet type="text/css" href="../../../colorbrewer/colorbrewer.css">
<script type="text/javascript" src="../curvechart.js"></script>
View
14 inst/panels/dotchart/dotchart.coffee
@@ -344,17 +344,3 @@ dotchart = () ->
# return the chart function
chart
-
-# function to determine rounding of axis labels
-formatAxis = (d) ->
- d = d[1] - d[0]
- ndig = Math.floor( Math.log(d % 10) / Math.log(10) )
- ndig = 0 if ndig > 0
- ndig = Math.abs(ndig)
- d3.format(".#{ndig}f")
-
-# unique values of array (ignore nulls)
-unique = (x) ->
- output = {}
- output[v] = v for v in x when v
- output[v] for v of output
View
29 inst/panels/dotchart/dotchart.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var dotchart, formatAxis, unique,
+var dotchart,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
dotchart = function() {
@@ -365,30 +365,3 @@ dotchart = function() {
};
return chart;
};
-
-formatAxis = function(d) {
- var ndig;
- d = d[1] - d[0];
- ndig = Math.floor(Math.log(d % 10) / Math.log(10));
- if (ndig > 0) {
- ndig = 0;
- }
- ndig = Math.abs(ndig);
- return d3.format("." + ndig + "f");
-};
-
-unique = function(x) {
- var output, v, _i, _len, _results;
- output = {};
- for (_i = 0, _len = x.length; _i < _len; _i++) {
- v = x[_i];
- if (v) {
- output[v] = v;
- }
- }
- _results = [];
- for (v in output) {
- _results.push(output[v]);
- }
- return _results;
-};
View
1 inst/panels/dotchart/test/index.html
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Test of reusable dotchart</title>
+ <script type="text/javascript" src="../../panelutil.js"></script>
<script charset="utf-8" type="text/javascript" src="../../../d3/d3.min.js"></script>
<link rel=stylesheet type="text/css" href="../../../d3-tip/d3-tip.min.css">
<script type="text/javascript" src="../../../d3-tip/d3-tip.min.js"></script>
View
59 inst/panels/lodchart/lodchart.coffee
@@ -61,7 +61,7 @@ lodchart = () ->
yticks = yticks ? yscale.ticks(nyticks)
# reorganize lod,pos by chromosomes
- data = reorgData(data, lodvarname)
+ data = reorgLodData(data, lodvarname)
# add chromosome scales (for x-axis)
data = chrscales(data, width, chrGap)
@@ -316,60 +316,3 @@ lodchart = () ->
# return the chart function
chart
-
-# function to determine rounding of axis labels
-formatAxis = (d) ->
- d = d[1] - d[0]
- ndig = Math.floor( Math.log(d % 10) / Math.log(10) )
- ndig = 0 if ndig > 0
- ndig = Math.abs(ndig)
- d3.format(".#{ndig}f")
-
-# reorganize lod/pos in data by chromosome
-reorgData = (data, lodvarname) ->
- data.posByChr = {}
- data.lodByChr = {}
- for chr,i in data.chrnames
- data.posByChr[chr] = []
- data.lodByChr[chr] = []
- for pos,j in data.pos
- data.posByChr[chr].push(pos) if data.chr[j] == chr
- data.lodByChr[chr].push(data[lodvarname][j]) if data.chr[j] == chr
- data.markers = []
- for marker,i in data.markernames
- if marker != ""
- data.markers.push({name:marker, chr:data.chr[i], pos:data.pos[i], lod:data[lodvarname][i]})
- data
-
-# calculate chromosome start/end + scales
-chrscales = (data, width, chrGap) ->
- # start and end of chromosome positions
- chrStart = []
- chrEnd = []
- chrLength = []
- totalChrLength = 0
- for chr in data.chrnames
- rng = d3.extent(data.posByChr[chr])
- chrStart.push(rng[0])
- chrEnd.push(rng[1])
- L = rng[1] - rng[0]
- chrLength.push(L)
- totalChrLength += L
-
- # break up x axis into chromosomes by length, with gaps
- data.chrStart = []
- data.chrEnd = []
- cur = Math.round(chrGap/2)
- data.xscale = {}
- for chr,i in data.chrnames
- data.chrStart.push(cur)
- w = Math.round((width-chrGap*data.chrnames.length)/totalChrLength*chrLength[i])
- data.chrEnd.push(cur + w)
- cur = data.chrEnd[i] + chrGap
- # x-axis scales, by chromosome
- data.xscale[chr] = d3.scale.linear()
- .domain([chrStart[i], chrEnd[i]])
- .range([data.chrStart[i], data.chrEnd[i]])
-
- # return data with new stuff added
- data
View
83 inst/panels/lodchart/lodchart.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var chrscales, formatAxis, lodchart, reorgData;
+var lodchart;
lodchart = function() {
var axispos, chart, chrGap, chrSelect, darkrect, height, lightrect, linecolor, linewidth, lodcurve, lodvarname, margin, markerSelect, nyticks, pointcolor, pointsize, title, titlepos, width, xlab, xscale, ylab, ylim, yscale, yticks;
@@ -49,7 +49,7 @@ lodchart = function() {
g.append("rect").attr("x", 0).attr("y", 0).attr("height", height).attr("width", width).attr("fill", darkrect).attr("stroke", "none");
yscale.domain(ylim).range([height, margin.inner]);
yticks = yticks != null ? yticks : yscale.ticks(nyticks);
- data = reorgData(data, lodvarname);
+ data = reorgLodData(data, lodvarname);
data = chrscales(data, width, chrGap);
xscale = data.xscale;
chrSelect = g.append("g").attr("class", "chrRect").selectAll("empty").data(data.chrnames).enter().append("rect").attr("id", function(d) {
@@ -275,82 +275,3 @@ lodchart = function() {
};
return chart;
};
-
-formatAxis = function(d) {
- var ndig;
- d = d[1] - d[0];
- ndig = Math.floor(Math.log(d % 10) / Math.log(10));
- if (ndig > 0) {
- ndig = 0;
- }
- ndig = Math.abs(ndig);
- return d3.format("." + ndig + "f");
-};
-
-reorgData = function(data, lodvarname) {
- var chr, i, j, marker, pos, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
- data.posByChr = {};
- data.lodByChr = {};
- _ref = data.chrnames;
- for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
- chr = _ref[i];
- data.posByChr[chr] = [];
- data.lodByChr[chr] = [];
- _ref1 = data.pos;
- for (j = _j = 0, _len1 = _ref1.length; _j < _len1; j = ++_j) {
- pos = _ref1[j];
- if (data.chr[j] === chr) {
- data.posByChr[chr].push(pos);
- }
- if (data.chr[j] === chr) {
- data.lodByChr[chr].push(data[lodvarname][j]);
- }
- }
- }
- data.markers = [];
- _ref2 = data.markernames;
- for (i = _k = 0, _len2 = _ref2.length; _k < _len2; i = ++_k) {
- marker = _ref2[i];
- if (marker !== "") {
- data.markers.push({
- name: marker,
- chr: data.chr[i],
- pos: data.pos[i],
- lod: data[lodvarname][i]
- });
- }
- }
- return data;
-};
-
-chrscales = function(data, width, chrGap) {
- var L, chr, chrEnd, chrLength, chrStart, cur, i, rng, totalChrLength, w, _i, _j, _len, _len1, _ref, _ref1;
- chrStart = [];
- chrEnd = [];
- chrLength = [];
- totalChrLength = 0;
- _ref = data.chrnames;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- chr = _ref[_i];
- rng = d3.extent(data.posByChr[chr]);
- chrStart.push(rng[0]);
- chrEnd.push(rng[1]);
- L = rng[1] - rng[0];
- chrLength.push(L);
- totalChrLength += L;
- }
- data.chrStart = [];
- data.chrEnd = [];
- cur = Math.round(chrGap / 2);
- data.xscale = {};
- _ref1 = data.chrnames;
- for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) {
- chr = _ref1[i];
- data.chrStart.push(cur);
- w = Math.round((width - chrGap * data.chrnames.length) / totalChrLength * chrLength[i]);
- data.chrEnd.push(cur + w);
- cur = data.chrEnd[i] + chrGap;
- data.xscale[chr] = d3.scale.linear().domain([chrStart[i], chrEnd[i]]).range([data.chrStart[i], data.chrEnd[i]]);
- }
- return data;
-};
View
1 inst/panels/lodchart/test/index.html
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Test of reusable LOD score chart</title>
+ <script type="text/javascript" src="../../panelutil.js"></script>
<script charset="utf-8" type="text/javascript" src="../../../d3/d3.min.js"></script>
<link rel=stylesheet type="text/css" href="../../../d3-tip/d3-tip.min.css">
<script type="text/javascript" src="../../../d3-tip/d3-tip.min.js"></script>
View
71 inst/panels/panelutil.coffee
@@ -0,0 +1,71 @@
+# A variety of utility functions used by the different panel functions
+
+# function to determine rounding of axis labels
+formatAxis = (d) ->
+ d = d[1] - d[0]
+ ndig = Math.floor( Math.log(d % 10) / Math.log(10) )
+ ndig = 0 if ndig > 0
+ ndig = Math.abs(ndig)
+ d3.format(".#{ndig}f")
+
+# unique values of array (ignore nulls)
+unique = (x) ->
+ output = {}
+ output[v] = v for v in x when v
+ output[v] for v of output
+
+# Pull out a variable (column) from a two-dimensional array
+pullVarAsArray = (data, variable) ->
+ v = []
+ for i of data
+ v = v.concat data[i][variable]
+ v
+
+# calculate chromosome start/end + scales
+chrscales = (data, width, chrGap) ->
+ # start and end of chromosome positions
+ chrStart = []
+ chrEnd = []
+ chrLength = []
+ totalChrLength = 0
+ for chr in data.chrnames
+ rng = d3.extent(data.posByChr[chr])
+ chrStart.push(rng[0])
+ chrEnd.push(rng[1])
+ L = rng[1] - rng[0]
+ chrLength.push(L)
+ totalChrLength += L
+
+ # break up x axis into chromosomes by length, with gaps
+ data.chrStart = []
+ data.chrEnd = []
+ cur = Math.round(chrGap/2)
+ data.xscale = {}
+ for chr,i in data.chrnames
+ data.chrStart.push(cur)
+ w = Math.round((width-chrGap*data.chrnames.length)/totalChrLength*chrLength[i])
+ data.chrEnd.push(cur + w)
+ cur = data.chrEnd[i] + chrGap
+ # x-axis scales, by chromosome
+ data.xscale[chr] = d3.scale.linear()
+ .domain([chrStart[i], chrEnd[i]])
+ .range([data.chrStart[i], data.chrEnd[i]])
+
+ # return data with new stuff added
+ data
+
+# reorganize lod/pos in data by chromosome
+reorgLodData = (data, lodvarname) ->
+ data.posByChr = {}
+ data.lodByChr = {}
+ for chr,i in data.chrnames
+ data.posByChr[chr] = []
+ data.lodByChr[chr] = []
+ for pos,j in data.pos
+ data.posByChr[chr].push(pos) if data.chr[j] == chr
+ data.lodByChr[chr].push(data[lodvarname][j]) if data.chr[j] == chr
+ data.markers = []
+ for marker,i in data.markernames
+ if marker != ""
+ data.markers.push({name:marker, chr:data.chr[i], pos:data.pos[i], lod:data[lodvarname][i]})
+ data
View
106 inst/panels/panelutil.js
@@ -0,0 +1,106 @@
+// Generated by CoffeeScript 1.6.3
+var chrscales, formatAxis, pullVarAsArray, reorgLodData, unique;
+
+formatAxis = function(d) {
+ var ndig;
+ d = d[1] - d[0];
+ ndig = Math.floor(Math.log(d % 10) / Math.log(10));
+ if (ndig > 0) {
+ ndig = 0;
+ }
+ ndig = Math.abs(ndig);
+ return d3.format("." + ndig + "f");
+};
+
+unique = function(x) {
+ var output, v, _i, _len, _results;
+ output = {};
+ for (_i = 0, _len = x.length; _i < _len; _i++) {
+ v = x[_i];
+ if (v) {
+ output[v] = v;
+ }
+ }
+ _results = [];
+ for (v in output) {
+ _results.push(output[v]);
+ }
+ return _results;
+};
+
+pullVarAsArray = function(data, variable) {
+ var i, v;
+ v = [];
+ for (i in data) {
+ v = v.concat(data[i][variable]);
+ }
+ return v;
+};
+
+chrscales = function(data, width, chrGap) {
+ var L, chr, chrEnd, chrLength, chrStart, cur, i, rng, totalChrLength, w, _i, _j, _len, _len1, _ref, _ref1;
+ chrStart = [];
+ chrEnd = [];
+ chrLength = [];
+ totalChrLength = 0;
+ _ref = data.chrnames;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ chr = _ref[_i];
+ rng = d3.extent(data.posByChr[chr]);
+ chrStart.push(rng[0]);
+ chrEnd.push(rng[1]);
+ L = rng[1] - rng[0];
+ chrLength.push(L);
+ totalChrLength += L;
+ }
+ data.chrStart = [];
+ data.chrEnd = [];
+ cur = Math.round(chrGap / 2);
+ data.xscale = {};
+ _ref1 = data.chrnames;
+ for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) {
+ chr = _ref1[i];
+ data.chrStart.push(cur);
+ w = Math.round((width - chrGap * data.chrnames.length) / totalChrLength * chrLength[i]);
+ data.chrEnd.push(cur + w);
+ cur = data.chrEnd[i] + chrGap;
+ data.xscale[chr] = d3.scale.linear().domain([chrStart[i], chrEnd[i]]).range([data.chrStart[i], data.chrEnd[i]]);
+ }
+ return data;
+};
+
+reorgLodData = function(data, lodvarname) {
+ var chr, i, j, marker, pos, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
+ data.posByChr = {};
+ data.lodByChr = {};
+ _ref = data.chrnames;
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
+ chr = _ref[i];
+ data.posByChr[chr] = [];
+ data.lodByChr[chr] = [];
+ _ref1 = data.pos;
+ for (j = _j = 0, _len1 = _ref1.length; _j < _len1; j = ++_j) {
+ pos = _ref1[j];
+ if (data.chr[j] === chr) {
+ data.posByChr[chr].push(pos);
+ }
+ if (data.chr[j] === chr) {
+ data.lodByChr[chr].push(data[lodvarname][j]);
+ }
+ }
+ }
+ data.markers = [];
+ _ref2 = data.markernames;
+ for (i = _k = 0, _len2 = _ref2.length; _k < _len2; i = ++_k) {
+ marker = _ref2[i];
+ if (marker !== "") {
+ data.markers.push({
+ name: marker,
+ chr: data.chr[i],
+ pos: data.pos[i],
+ lod: data[lodvarname][i]
+ });
+ }
+ }
+ return data;
+};
View
8 inst/panels/scatterplot/scatterplot.coffee
@@ -378,11 +378,3 @@ scatterplot = () ->
# return the chart function
chart
-
-# function to determine rounding of axis labels
-formatAxis = (d) ->
- d = d[1] - d[0]
- ndig = Math.floor( Math.log(d % 10) / Math.log(10) )
- ndig = 0 if ndig > 0
- ndig = Math.abs(ndig)
- d3.format(".#{ndig}f")
View
13 inst/panels/scatterplot/scatterplot.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var formatAxis, scatterplot;
+var scatterplot;
scatterplot = function() {
var axispos, chart, dataByInd, height, margin, nxticks, nyticks, pointcolor, pointsSelect, pointsize, pointstroke, rectcolor, title, titlepos, width, xNA, xlab, xlim, xscale, xticks, xvar, yNA, ylab, ylim, yscale, yticks, yvar;
@@ -367,14 +367,3 @@ scatterplot = function() {
};
return chart;
};
-
-formatAxis = function(d) {
- var ndig;
- d = d[1] - d[0];
- ndig = Math.floor(Math.log(d % 10) / Math.log(10));
- if (ndig > 0) {
- ndig = 0;
- }
- ndig = Math.abs(ndig);
- return d3.format("." + ndig + "f");
-};
View
1 inst/panels/scatterplot/test/index.html
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Test of reusable scatterplot</title>
+ <script type="text/javascript" src="../../panelutil.js"></script>
<script charset="utf-8" type="text/javascript" src="../../../d3/d3.min.js"></script>
<script type="text/javascript" src="../scatterplot.js"></script>

0 comments on commit e025993

Please sign in to comment.