@@ -35,7 +35,6 @@ <h1 class="page-title">Source: import/barChart.js</h1>
3535/**
3636 * Builds a Bar Chart.
3737 * @constructor
38- * @param {String} mode (init / refresh)
3938 * @exports barChart
4039 */
4140
@@ -61,52 +60,51 @@ <h1 class="page-title">Source: import/barChart.js</h1>
6160 },
6261 };
6362
64-
6563 /**
66- * @method getWidth
67- * @param {Object} d (svg element)
68- * @description Returns width of the bar
69- */
64+ * @method getWidth
65+ * @param {Object} d (svg element)
66+ * @description Returns width of the bar
67+ */
7068 const getWidth = d => cs.x.scale(d.metric);
7169
72- /**
73- * @method getHeight
74- * @description Returns height of the bar
75- */
70+ /**
71+ * @method getHeight
72+ * @description Returns height of the bar
73+ */
7674 const getHeight = () => (
77- this.height - cs.x.axisHeight - this.header - cs.bar.vPadding) / this.ds.length - 1;
75+ this.displayHeight - cs.x.axisHeight - this.header - cs.bar.vPadding) / this.ds.length - 1;
7876
7977 /**
80- * @method getYCoord
81- * @param {Object} d (svg element)
82- * @param {Object} i (svg element)
83- * @description Returns y axis co-ordinate of the bar
84- */
78+ * @method getYCoord
79+ * @param {Object} d (svg element)
80+ * @param {Object} i (svg element)
81+ * @description Returns y axis co-ordinate of the bar
82+ */
8583 const getYCoord = (d, i) => i * (
86- this.height - cs.x.axisHeight - this.header) / this.ds.length + 1 + this.header;
84+ this.displayHeight - cs.x.axisHeight - this.header) / this.ds.length + 1 + this.header;
8785
8886 /**
89- * @method mouseOver
90- * @param {Object} d (svg element)
91- * @description Adds a tooltip on mouse over
92- */
87+ * @method mouseOver
88+ * @param {Object} d (svg element)
89+ * @description Adds a tooltip on mouse over
90+ */
9391 const mouseOver = (d) => {
9492 this.addTooltip(d, window.event);
9593 };
9694
9795 /**
98- * @method mouseOut
99- * @param {Object} d (svg element)
100- * @description Removes tooltip on mouse out
101- */
96+ * @method mouseOut
97+ * @param {Object} d (svg element)
98+ * @description Removes tooltip on mouse out
99+ */
102100 const mouseOut = (d) => {
103101 this.removeTooltip(d);
104102 };
105- /**
106- * @method enter
107- * @param {Object} rects (svg element)
108- * @description Runs when a new element is added to the dataset
109- */
103+ /**
104+ * @method enter
105+ * @param {Object} rects (svg element)
106+ * @description Runs when a new element is added to the dataset
107+ */
110108 const enter = (rects) => {
111109 rects.enter()
112110 .append('rect')
@@ -121,11 +119,11 @@ <h1 class="page-title">Source: import/barChart.js</h1>
121119 .on('mouseout', mouseOut);
122120 return rects;
123121 };
124- /**
125- * @method transition
126- * @param {Object} rects (svg element)
127- * @description Runs when a value of an element in dataset is changed
128- */
122+ /**
123+ * @method transition
124+ * @param {Object} rects (svg element)
125+ * @description Runs when a value of an element in dataset is changed
126+ */
129127 const transition = (rects) => {
130128 rects.transition()
131129 .attr('width', getWidth)
@@ -134,59 +132,66 @@ <h1 class="page-title">Source: import/barChart.js</h1>
134132 .attr('x', cs.y.axisWidth + cs.bar.hPadding);
135133 return rects;
136134 };
137- /**
138- * @method exit
139- * @param {Object} rect (svg element)
140- * @description Runs when an element is removed from the dataset
141- */
135+ /**
136+ * @method exit
137+ * @param {Object} rect (svg element)
138+ * @description Runs when an element is removed from the dataset
139+ */
142140 const exit = (rects) => {
143141 rects.exit().remove();
144142 return rects;
145143 };
146- /**
147- * @method buildScales
148- * @description builds the scales for the x and y axes
149- */
144+ /**
145+ * @method buildScales
146+ * @description builds the scales for the x and y axes
147+ */
150148 const buildScales = () => {
151149 cs.x.scale = d3.scaleLinear()
152150 .domain([0, this.max])
153151 .range([0, this.width - cs.bar.hPadding - cs.y.axisWidth]);
154152 this.ds.forEach(t => cs.y.domain.push(t.dim));
155153 this.ds.forEach((t, i) => cs.y.range.push(((
156- this.chartData.height - cs.x.axisHeight - this.header + cs.bar.vPadding) * i) / this.ds.length));
154+ this.displayHeight - cs.x.axisHeight - this.header + cs.bar.vPadding) * i) / this.ds.length));
157155 cs.y.scale = d3.scaleOrdinal().domain(cs.y.domain).range(cs.y.range);
158156 };
159- /**
160- * @method drawAxis
161- * @description draws the x and y axes on the svg
162- */
157+ /**
158+ * @method drawAxis
159+ * @description draws the x and y axes on the svg
160+ */
163161 const drawAxis = () => {
164162 cs.x.axis = d3.axisBottom().ticks(cs.x.ticks, 's').scale(cs.x.scale);
165163 cs.y.axis = d3.axisLeft().scale(cs.y.scale);
166- cs.x.yOffset = this.height - cs.x.axisHeight;
164+ cs.x.yOffset = this.displayHeight - cs.x.axisHeight;
167165 cs.x.xOffset = cs.bar.hPadding + cs.y.axisWidth;
168166 cs.y.yOffset = cs.bar.vPadding + this.header - 1;
169167 cs.y.xOffset = cs.y.axisWidth;
170168 if (this.ds[0].dim)
171169 svgContainer.append('g').attr('class', 'axis').attr('transform', `translate(${cs.y.xOffset}, ${cs.y.yOffset})`).call(cs.y.axis);
172170 svgContainer.append('g').attr('class', 'axis').attr('transform', `translate(${cs.x.xOffset}, ${cs.x.yOffset})`).call(cs.x.axis);
173171 };
174-
172+ /**
173+ * @method getMaxDimLength
174+ * @param {number} accumulator
175+ * @param {number} currentValue
176+ * @description get the maximum dimension length
177+ */
175178 const getMaxDimLength = (accumulator, currentValue) => {
176179 return (currentValue.dim.length > accumulator) ? currentValue.dim.length : accumulator;
177180 }
178181
179182 const rects = svgContainer.selectAll('rect').data(this.ds);
180183
181- cs = this.setOverrides(cs, this.chartData.overrides);
184+ cs = this.setOverrides(cs, this.chartData.overrides);
182185 if (this.ds[0].dim)
183186 cs.y.axisWidth = cs.y.axisWidth || (this.ds.reduce(getMaxDimLength, 0)) * 10;
184-
187+
185188 buildScales(cs);
186189 drawAxis(cs);
187190 enter(rects);
188191 transition(rects);
189192 exit(rects);
193+
194+ return cs;
190195};
191196
192197export default barChart;
@@ -200,13 +205,13 @@ <h1 class="page-title">Source: import/barChart.js</h1>
200205</ div >
201206
202207< nav >
203- < h2 > < a href ="index.html "> Home</ a > </ h2 > < h3 > Modules</ h3 > < ul > < li > < a href ="module-areaChart.html "> areaChart</ a > </ li > < li > < a href ="module-barChart.html "> barChart</ a > </ li > < li > < a href ="module-lineGraph.html "> lineGraph</ a > </ li > < li > < a href ="module-pieChart.html "> pieChart</ a > </ li > < li > < a href ="module-scatterPlot.html "> scatterPlot</ a > </ li > < li > < a href ="module-v-chart-plugin-module .html "> v-chart-plugin-module </ a > </ li > < li > < a href ="module-vBarChart .html "> vBarChart </ a > </ li > </ ul >
208+ < h2 > < a href ="index.html "> Home</ a > </ h2 > < h3 > Modules</ h3 > < ul > < li > < a href ="module-areaChart.html "> areaChart</ a > </ li > < li > < a href ="module-barChart.html "> barChart</ a > </ li > < li > < a href ="module-lineGraph.html "> lineGraph</ a > </ li > < li > < a href ="module-pieChart.html "> pieChart</ a > </ li > < li > < a href ="module-scatterPlot.html "> scatterPlot</ a > </ li > < li > < a href ="module-vBarChart .html "> vBarChart </ a > </ li > </ ul > < h3 > Namespaces </ h3 > < ul > < li > < a href ="Chart .html "> Chart </ a > </ li > </ ul >
204209</ nav >
205210
206211< br class ="clear ">
207212
208213< footer >
209- Documentation generated by < a href ="https://github.com/jsdoc3/jsdoc "> JSDoc 3.5.5</ a > on Tue Oct 30 2018 22:19:35 GMT-0400 (EDT)
214+ Documentation generated by < a href ="https://github.com/jsdoc3/jsdoc "> JSDoc 3.5.5</ a > on Wed Oct 31 2018 22:03:17 GMT-0400 (EDT)
210215</ footer >
211216
212217< script > prettyPrint ( ) ; </ script >
0 commit comments