Исправлена работа Area графика

This commit is contained in:
goodmice 2022-07-03 19:29:27 +05:00
parent 1402e6ce67
commit d23e295746

View File

@ -13,15 +13,16 @@ export const renderArea = <DataType extends Record<string, unknown>>(
let area = d3.area()
if (chart.y0) {
area = area.y0(chart.y0)
if ('y0' in chart) {
area = area.y0(yAxis(chart.y0 ?? 0))
.y1(d => yAxis(chart.y(d)))
console.log('setting const y')
} else {
area = area.y(d => yAxis(chart.y(d)))
}
if (chart.x0) {
area = area.x0(chart.x0)
if ('x0' in chart) {
area = area.x0(xAxis(chart.x0 ?? 0))
.x1(d => xAxis(chart.x(d)))
} else {
area = area.x(d => xAxis(chart.x(d)))
@ -52,6 +53,7 @@ export const renderArea = <DataType extends Record<string, unknown>>(
.duration(chart.animDurationMs || 0)
.attr('d', area(data as any))
.attr('stroke-dasharray', chart.dash ? String(chart.dash) : null)
.attr('fill', chart.areaColor ?? null)
return data
}