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

Can someone help with coloring seriesWebglPoint() ? #10

Open
jodusan opened this issue Oct 17, 2021 · 0 comments
Open

Can someone help with coloring seriesWebglPoint() ? #10

jodusan opened this issue Oct 17, 2021 · 0 comments

Comments

@jodusan
Copy link

jodusan commented Oct 17, 2021

I am trying to color datapoints from d.color property but it is not working, in the console I get the error

Uncaught Error: Failed to compile shader : ERROR: 0:12: 'canStroke' : undeclared identifier
ERROR: 0:12: 'canStroke' : undeclared identifier

            Shader : 
precision mediump float;
varying float vSize;
varying vec4 vStrokeColor;
void main() {
    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
    float distance = length(2.0 * gl_PointCoord - 1.0);
    if (distance > 1.0) {
        discard;
        return;
    }
gl_FragColor = (canStroke * vStrokeColor) + ((1.0 - canStroke) * gl_FragColor);
gl_FragColor.a = gl_FragColor.a * (1.0 - smoothstep(vSize - 2.0, vSize, distance * vSize));
}
    at loadShader (d3fc.js:3275)
    at createProgram (d3fc.js:3250)
    at build (d3fc.js:3181)
    at draw (d3fc.js:3939)
    at point (d3fc.js:5331)
    at HTMLElement.<anonymous> (d3fc.js:8577)
    at HTMLElement.<anonymous> (on.js:27)
    at draw (d3fc.js:8116)
    at Array.forEach (<anonymous>)
    at redraw (d3fc.js:8123)
    at d3fc.js:8138

for the following js code

const pointSeries = fc
                .seriesWebglPoint()
                .crossValue(d => d.x)
                .mainValue(d => d.y)
                .size(d => 80)
                .decorate((program, data) => {
                    idx+=1;
                    
                    fcgl.webglStrokeColor().value(d=>d.color).data(data)(program);
                   
                    fc.pointAntiAlias()(program);

                    const gl = program.context();
                    gl.enable(gl.BLEND);
                    gl.blendFuncSeparate(
                        gl.SRC_ALPHA,
                        gl.ONE_MINUS_DST_ALPHA,
                        gl.ONE,
                        gl.ONE_MINUS_SRC_ALPHA
                    );
                });

Can someone help with this library? Learning curve is worse than vim, are there any good tutorials?

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

No branches or pull requests

1 participant