[fix] zero bar height positive

This commit is contained in:
Prateeksha Singh 2018-04-19 05:17:19 +05:30
parent 2c6032978e
commit 436685872e
10 changed files with 20 additions and 24 deletions

View File

@ -297,10 +297,6 @@ class SvgTip {
} }
} }
/**
* Returns the value of a number upto 2 decimal places.
* @param {Number} d Any number
*/
function floatTwo(d) { function floatTwo(d) {
return parseFloat(d.toFixed(2)); return parseFloat(d.toFixed(2));
} }
@ -871,6 +867,11 @@ function datasetBar(x, yTop, width, color, label='', index=0, offset=0, meta={})
let [height, y] = getBarHeightAndYAttr(yTop, meta.zeroLine); let [height, y] = getBarHeightAndYAttr(yTop, meta.zeroLine);
y -= offset; y -= offset;
if(height === 0) {
height = meta.minHeight;
y -= meta.minHeight;
}
let rect = createSVG('rect', { let rect = createSVG('rect', {
className: `bar mini`, className: `bar mini`,
style: `fill: ${color}`, style: `fill: ${color}`,
@ -878,7 +879,7 @@ function datasetBar(x, yTop, width, color, label='', index=0, offset=0, meta={})
x: x, x: x,
y: y, y: y,
width: width, width: width,
height: height || meta.minHeight // TODO: correct y for positive min height height: height
}); });
label += ""; label += "";
@ -966,7 +967,6 @@ function getPaths(xList, yList, color, options={}, meta={}) {
if(options.regionFill) { if(options.regionFill) {
let gradient_id_region = makeGradient(meta.svgDefs, color, true); let gradient_id_region = makeGradient(meta.svgDefs, color, true);
// TODO: use zeroLine OR minimum
let pathStr = "M" + `${xList[0]},${meta.zeroLine}L` + pointsStr + `L${xList.slice(-1)[0]},${meta.zeroLine}`; let pathStr = "M" + `${xList[0]},${meta.zeroLine}L` + pointsStr + `L${xList.slice(-1)[0]},${meta.zeroLine}`;
paths.region = makePath(pathStr, `region-fill`, 'none', `url(#${gradient_id_region})`); paths.region = makePath(pathStr, `region-fill`, 'none', `url(#${gradient_id_region})`);
} }
@ -3642,7 +3642,6 @@ class AxisChart extends BaseChart {
// removeDataPoint(index = 0) {} // removeDataPoint(index = 0) {}
} }
// import MultiAxisChart from './charts/MultiAxisChart';
const chartTypes = { const chartTypes = {
bar: AxisChart, bar: AxisChart,
line: AxisChart, line: AxisChart,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -46,12 +46,6 @@ var HEATMAP_COLORS_YELLOW = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001
// Universal constants // Universal constants
/**
* Returns the value of a number upto 2 decimal places.
* @param {Number} d Any number
*/
/** /**
* Returns whether or not two given arrays are equal. * Returns whether or not two given arrays are equal.
* @param {Array} arr1 First array * @param {Array} arr1 First array
@ -120,6 +114,7 @@ var MONTH_NAMES_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
// https://stackoverflow.com/a/11252167/6495043
function clone(date) { function clone(date) {
@ -299,8 +294,6 @@ var heatmapData = {
end: end end: end
}; };
// ================================================================================
var c1 = document.querySelector("#chart-composite-1"); var c1 = document.querySelector("#chart-composite-1");
var c2 = document.querySelector("#chart-composite-2"); var c2 = document.querySelector("#chart-composite-2");

File diff suppressed because one or more lines are too long

View File

@ -454,6 +454,11 @@ export function datasetBar(x, yTop, width, color, label='', index=0, offset=0, m
let [height, y] = getBarHeightAndYAttr(yTop, meta.zeroLine); let [height, y] = getBarHeightAndYAttr(yTop, meta.zeroLine);
y -= offset; y -= offset;
if(height === 0) {
height = meta.minHeight;
y -= meta.minHeight;
}
let rect = createSVG('rect', { let rect = createSVG('rect', {
className: `bar mini`, className: `bar mini`,
style: `fill: ${color}`, style: `fill: ${color}`,
@ -461,7 +466,7 @@ export function datasetBar(x, yTop, width, color, label='', index=0, offset=0, m
x: x, x: x,
y: y, y: y,
width: width, width: width,
height: height || meta.minHeight // TODO: correct y for positive min height height: height
}); });
label += ""; label += "";
@ -549,7 +554,6 @@ export function getPaths(xList, yList, color, options={}, meta={}) {
if(options.regionFill) { if(options.regionFill) {
let gradient_id_region = makeGradient(meta.svgDefs, color, true); let gradient_id_region = makeGradient(meta.svgDefs, color, true);
// TODO: use zeroLine OR minimum
let pathStr = "M" + `${xList[0]},${meta.zeroLine}L` + pointsStr + `L${xList.slice(-1)[0]},${meta.zeroLine}`; let pathStr = "M" + `${xList[0]},${meta.zeroLine}L` + pointsStr + `L${xList.slice(-1)[0]},${meta.zeroLine}`;
paths.region = makePath(pathStr, `region-fill`, 'none', `url(#${gradient_id_region})`); paths.region = makePath(pathStr, `region-fill`, 'none', `url(#${gradient_id_region})`);
} }