瀏覽代碼

feat: add trailingDot option

pull/347/head
Shivam Mishra 4 年之前
committed by GitHub
父節點
當前提交
07597ebe87
共有 3 個文件被更改,包括 22 次插入4 次删除
  1. +2
    -0
      src/js/charts/AxisChart.js
  2. +18
    -2
      src/js/objects/ChartComponents.js
  3. +2
    -2
      src/js/utils/draw.js

+ 2
- 0
src/js/charts/AxisChart.js 查看文件

@@ -303,6 +303,8 @@ export default class AxisChart extends BaseChart {
regionFill: this.lineOptions.regionFill,
spline: this.lineOptions.spline,
showDots: this.lineOptions.showDots,
trailingDot: this.lineOptions.trailingDot,
hideDotBorder: this.lineOptions.hideDotBorder,
hideLine: this.lineOptions.hideLine,

// same for all datasets


+ 18
- 2
src/js/objects/ChartComponents.js 查看文件

@@ -384,7 +384,7 @@ let componentConfigs = {
);
}

this.units = [];
this.units = [];
if (c.showDots) {
this.units = data.yPositions.map((y, j) => {
return datasetDot(
@@ -393,11 +393,27 @@ let componentConfigs = {
data.radius,
c.color,
(c.valuesOverPoints ? data.values[j] : ''),
j
j,
c.hideDotBorder
);
});
}

if (c.trailingDot && !c.showDots) {
const lastIndex = data.yPositions.length - 1;
const dot = datasetDot(
data.xPositions[lastIndex],
data.yPositions[lastIndex],
data.radius,
c.color,
(c.valuesOverPoints ? data.values[lastIndex] : ''),
lastIndex,
c.hideDotBorder
);

this.units.push(dot);
}

return Object.values(this.paths).concat(this.units);
},
animateElements(newData) {


+ 2
- 2
src/js/utils/draw.js 查看文件

@@ -573,9 +573,9 @@ export function datasetBar(x, yTop, width, color, label = '', index = 0, offset
}
}

export function datasetDot(x, y, radius, color, label = '', index = 0) {
export function datasetDot(x, y, radius, color, label = '', index = 0, hideDotBorder = false) {
let dot = createSVG('circle', {
style: `fill: ${color}`,
style: `fill: ${color} ${hideDotBorder ? `stroke: ${color}`: ''}`,
'data-point-index': index,
cx: x,
cy: y,


Loading…
取消
儲存