Git Product home page Git Product logo

Comments (1)

YoussefV avatar YoussefV commented on May 25, 2024

Fixed, but now the commented out clause around the "draw" callback makes the graph disappear:

const chart = fc
  .chartCartesian(xScale, yScale)
  .canvasPlotArea(gridline)
  .webglPlotArea(candlesticks)
  .decorate((sel) => {
            sel
            .enter()
            .select('.webgl-plot-area')
            .raise()
            .on('measure', event => {
              const { width, height } = event.detail;
                xScale.range([0, width]);
                yScale.range([height, 0]);

                gl = container.querySelector('canvas').getContext('webgl');
                candlesticks.context(gl);
           })
           .on('click', () => {
            const domain = xScale.domain();
            const mid = (domain[1].valueOf() - domain[0].valueOf()) / 2;
            xScale.domain([domain[0], new Date(domain[1].valueOf() - mid)]);
            candlesticks.bandwidth(candlesticks.bandwidth()() * 2);
            container.requestRedraw();
           })
           .on('measure.bandwidth', (event, d) => { // statically updates bandwidth measure on screen stretch
                const { width } = event.detail;
                candlesticks.bandwidth(width/100.0);
           })
//           .on('draw', () => {
//               if (pixels == null) {
//                   pixels = new Uint8Array(
//                       gl.drawingBufferWidth * gl.drawingBufferHeight * 4
//                   );
//               }
//               performance.mark(`draw-start-${frame}`);
//               candlesticks(data);
//               // Force GPU to complete rendering to allow accurate performance measurements to be taken
//               gl.readPixels(
//                   0,
//                   0,
//                   gl.drawingBufferWidth,
//                   gl.drawingBufferHeight,
//                   gl.RGBA,
//                   gl.UNSIGNED_BYTE,
//                   pixels
//               );
//               performance.measure(`draw-duration-${frame}`, `draw-start-${frame}`);
//               frame++;
//           })
  })

d3.select('#chart')
    .datum(data)
    .call(chart);

container.requestRedraw();

from d3fc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.