Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webgl points series rendering below gridlines. #1763

Open
jessechiasson opened this issue Aug 22, 2022 · 2 comments
Open

Webgl points series rendering below gridlines. #1763

jessechiasson opened this issue Aug 22, 2022 · 2 comments

Comments

@jessechiasson
Copy link

jessechiasson commented Aug 22, 2022

How can I render my WebGL points on top of the SVG layer. I tried to use .order() but it didn't seem to work. The gridlines appear over my data points. Thanks for any help.

const gridlines = fc
        .annotationSvgGridline()
        .xScale(this.xScale)
        .xDecorate((selection) => {
          selection
          .attr("id","gridlines")
          .style('stroke-width',nextProps.show_gridlines?'1px':'0')
          .style('stroke','rbga(255,0,0,1)')
        })
        .yDecorate((selection) => {
          selection
          .attr("id","gridlines")
          .style('stroke-width',nextProps.show_gridlines?'1px':'0')
          .style('stroke','rbga(255,0,0,1)')
        })
...
const pointSeries = fc
        .seriesWebglPoint()
        .equals((a, b) => a === b)
        .size(this.toggle_alt_input_s ? d => Math.round(d.s) : nextProps.size_points)
        .crossValue(d => d.x)
        .mainValue(d => d.y)        
        .decorate(program => {
          this.toggle_alt_input_c > 0 ? colorScale(program) : fillColor(program);
          nextProps.toggle_dot_outline ? fc.webglStrokeColor([0, 0, 0, nextProps.points_opacity])(program) : fc.webglStrokeColor([0, 0, 0, 0])(program);
        })
        .type(symbolCircle);
...
const chart = fc
        .chartCartesian(this.xScale, this.yScale)                
        .webglPlotArea(            
          fc 
          .seriesWebglMulti()
          .series([ this.pointSeries ]) 
          .mapping((d, index, series) => {
            switch(series[index]) {
              case this.pointSeries:return d.data; 
            }
          }),
        )
        .svgPlotArea(          
          fc     
          .seriesSvgMulti()
          .series([current_line, gridlines])
          .mapping((data, index, series) => {
            switch(series[index]) {
              case current_line:
                return current_value;              
            }
          }),          
        )
        .yDecorate((sel_y, d) => {          
          d3.select('#chart')
            .select('.y-axis')
            .call(this.dragY)
            .attr("pointer-events", "none")
        })
        .xDecorate((sel_x, d) => {
          d3.select('#chart')
            .select('.x-axis')
            .call(this.dragX)
            .attr("pointer-events", "none")            
        })
        .decorate(sel => {  
            sel
            .selectAll("d3fc-svg")            
            .on("click", (event) => {
                this.handleClick(event)
            })  

            sel
            .enter()
            .select("d3fc-svg.plot-area")
            .select('svg')
            .attr('id','floor')
            .on("measure.range", (event) => {
                let detail = event.detail;
                this.xScaleOriginal.range([0, detail.width]);
                this.yScaleOriginal.range([detail.height, 0]);
            })                
            .call(this.selectedBehavior)

            sel
            .select(".webgl-plot-area.plot-area")
            .enter()
            .on('measure', event => {
              const { width, height } = event.detail;
              this.xScale.range([0, width]);
              this.yScale.range([height, 0]);
           })
            .call(this.pointer)           
                               
            const svgPlot = sel.enter()
            .select("d3fc-svg.plot-area")
            .node()

            const webglPlot = sel.enter()
            .select(".webgl-plot-area.plot-area")
            .node()

            sel
            .selectAll([webglPlot,svgPlot])
            .order();            
            
          }            
        ); 

` 
@chrisprice
Copy link
Contributor

chrisprice commented Aug 22, 2022 via email

@jessechiasson
Copy link
Author

.raise() worked brilliantly. Thanks so much, really appreciate it. I didn't see that in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants