1- import { area as shapeArea , create , group } from "d3" ;
1+ import { area as shapeArea , create } from "d3" ;
22import { Curve } from "../curve.js" ;
3- import { defined } from "../defined.js" ;
43import { Mark } from "../plot.js" ;
54import { indexOf , maybeZ } from "../options.js" ;
6- import { applyDirectStyles , applyIndirectStyles , applyTransform , applyGroupedChannelStyles } from "../style.js" ;
5+ import { applyDirectStyles , applyIndirectStyles , applyTransform , applyGroupedChannelStyles , groupIndex } from "../style.js" ;
76import { maybeIdentityX , maybeIdentityY } from "../transforms/identity.js" ;
87import { maybeStackX , maybeStackY } from "../transforms/stack.js" ;
98
@@ -19,31 +18,33 @@ export class Area extends Mark {
1918 super (
2019 data ,
2120 [
22- { name : "x1" , value : x1 , filter : null , scale : "x" } ,
23- { name : "y1" , value : y1 , filter : null , scale : "y" } ,
24- { name : "x2" , value : x2 , filter : null , scale : "x" , optional : true } ,
25- { name : "y2" , value : y2 , filter : null , scale : "y" , optional : true } ,
21+ { name : "x1" , value : x1 , scale : "x" } ,
22+ { name : "y1" , value : y1 , scale : "y" } ,
23+ { name : "x2" , value : x2 , scale : "x" , optional : true } ,
24+ { name : "y2" , value : y2 , scale : "y" , optional : true } ,
2625 { name : "z" , value : maybeZ ( options ) , optional : true }
2726 ] ,
2827 options ,
2928 defaults
3029 ) ;
3130 this . curve = Curve ( curve , tension ) ;
3231 }
32+ filter ( I ) {
33+ return I ;
34+ }
3335 render ( I , { x, y} , channels , dimensions ) {
34- const { x1 : X1 , y1 : Y1 , x2 : X2 = X1 , y2 : Y2 = Y1 , z : Z } = channels ;
36+ const { x1 : X1 , y1 : Y1 , x2 : X2 = X1 , y2 : Y2 = Y1 } = channels ;
3537 const { dx, dy} = this ;
3638 return create ( "svg:g" )
3739 . call ( applyIndirectStyles , this , dimensions )
3840 . call ( applyTransform , x , y , dx , dy )
3941 . call ( g => g . selectAll ( )
40- . data ( Z ? group ( I , i => Z [ i ] ) . values ( ) : [ I ] )
42+ . data ( groupIndex ( I , [ X1 , Y1 , X2 , Y2 ] , channels ) )
4143 . join ( "path" )
4244 . call ( applyDirectStyles , this )
4345 . call ( applyGroupedChannelStyles , this , channels )
4446 . attr ( "d" , shapeArea ( )
4547 . curve ( this . curve )
46- . defined ( i => defined ( X1 [ i ] ) && defined ( Y1 [ i ] ) && defined ( X2 [ i ] ) && defined ( Y2 [ i ] ) )
4748 . x0 ( i => X1 [ i ] )
4849 . y0 ( i => Y1 [ i ] )
4950 . x1 ( i => X2 [ i ] )
0 commit comments