Skip to content
Snippets Groups Projects
Verified Commit 4a801f71 authored by BARBIER Marc's avatar BARBIER Marc
Browse files

fix holes inside graph

parent 017e435f
No related branches found
No related tags found
No related merge requests found
......@@ -22,14 +22,14 @@ type LineElement = {
color: string
}
type SelfScalledLineElement = {
type SelfScaledLineElement = {
type: 'SelfScalledLine',
label: string,
data: number[],
color: string
}
type ChartElement = BlockElement | LineElement | BackgroundElement | SelfScalledLineElement
type ChartElement = BlockElement | LineElement | BackgroundElement | SelfScaledLineElement
export type { ChartElement, BlockElement, LineElement, BackgroundElement }
......@@ -93,14 +93,13 @@ export default defineComponent({
break
}
case 'Line': {
console.log( element.data)
for(const [ index, data ] of element.data.entries()) {
const placementRatio = (data - minY) / ( maxY - minY)
const placementHeight = height - scaleHeight - ( placementRatio * ( height - scaleHeight ) )
const nextPoint = element.data[index + 1]
if(!nextPoint) {
continue
if(nextPoint === undefined || nextPoint === null) {
break
}
const nextPlacementRatio = (nextPoint - minY) / ( maxY - minY)
const nextPlacementHeight = height - scaleHeight - ( nextPlacementRatio * ( height - scaleHeight ))
......@@ -118,23 +117,22 @@ export default defineComponent({
case 'SelfScalledLine': {
const min = element.data.reduce((prev, cur) => cur > prev ? cur : prev)
const max = element.data.reduce((prev, cur) => cur < prev ? cur : prev)
const selfScalledDataGap = ( width - scaleHeight ) / element.data.length
const selfScaledDataGap = ( width - scaleHeight ) / element.data.length
for(const [ index, data ] of element.data.entries()) {
const placementRatio = (data - min) / ( max - min)
const placementHeight = height - scaleHeight - ( placementRatio * ( height - scaleHeight ) )
const nextPoint = element.data[index + 1]
if(!nextPoint) break
if(nextPoint === undefined || nextPoint === null) break
const nextPlacementRatio = (nextPoint - min) / ( max - min)
const nextPlacementHeight = height - scaleHeight - nextPlacementRatio * ( height - scaleHeight )
this.drawConnectedPoints(context,
element.color,
index * selfScalledDataGap + scaleHeight,
index * selfScaledDataGap + scaleHeight,
placementHeight,
(index + 1) * selfScalledDataGap + scaleHeight,
(index + 1) * selfScaledDataGap + scaleHeight,
nextPlacementHeight
)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment