GithubHelp home page GithubHelp logo

Comments (6)

peterlaczkorailsware avatar peterlaczkorailsware commented on September 25, 2024 1

Sure, we want to create a dashboard about ad metrics and would like to have a table (among other charts) showing spending and performance stats (like ad spent amount, impressions and click-through rate) per campaign as well as totals on the bottom (or top). The thing is that some of those metrics have an easy grand total (like amount spent or impressions). For others, however, we would need a formula for example CTR is clicks / impressions. So it would need to work with the Math modifiers (as far as I understand we could load the impressions and clicks columns and create a third column using this modifier). Let me know if this makes sense or if you have any questions.

from highcharts.

karolkolodziej avatar karolkolodziej commented on September 25, 2024 1

Thank you both @peterlaczkorailsware @mcmastermind!
This gives us perspective on what you need!

from highcharts.

karolkolodziej avatar karolkolodziej commented on September 25, 2024

Hi @mcmastermind!
Thank you for sharing this idea! Right now we are in the process of defining what can be changed/improved in the datagrid so your input is very valuable to us!

To clarify, by footer do you mean something like this:
image

What would you like to show in the footer?

from highcharts.

peterlaczkorailsware avatar peterlaczkorailsware commented on September 25, 2024

Hey @karolkolodziej, I'm not the issue submitter but for us (currently evaluating HighCharts and starting a PoC) something like what you posted would be really valuable.

from highcharts.

karolkolodziej avatar karolkolodziej commented on September 25, 2024

Thank you @peterlaczkorailsware for your feedback.
Could you please provide more details on your specific requirements and how you envision this feature working for your use case?

from highcharts.

mcmastermind avatar mcmastermind commented on September 25, 2024

@karolkolodziej, I was able to come up with my own solution using the DataGrid resize event callback to fire a method that iterates over the rendered columns and adds the footer to the DataGrid component. The resize event is used because it fires after the grid is completely rendered and the component is set in Dashboards.boards.

image

Fortunately, my data is very static numbers, so a straight aggregate works well for me. I also added extra properties (such as prefix) to the column options that I can reference when adding the footer.

image

This method gets called in the resize event:

const addTotalRowToDataGrid = async evt => {
    const target = evt.target;
    // Wait for element to be available via mutationObserver in waitForElement
    const dataGridContainer = await waitForElement(`#${target.parentElement.id} .highcharts-datagrid-container`);

    // Remove existing footer if present
    dataGridContainer.querySelector('.highcharts-datagrid-footer-container')?.remove();

    const dataGridHeader = dataGridContainer.querySelector('.highcharts-datagrid-header-container'),
      data = target.connector.options.data,
      columnNames = target.connector.options.columnNames,
      columnOpts = target.options.dataGridOptions.columns,
      dataGridFooter = dataGridHeader.cloneNode(true),
      footerCols = dataGridFooter.querySelectorAll('.highcharts-datagrid-column-header');

    dataGridFooter.classList.add('highcharts-datagrid-footer-container');

    for (let i = 0, iLen = footerCols.length; i < iLen; i++) {
      const col = footerCols[i];
      if (i === 0) {
        // Add text to first/header column 
        col.innerText = 'Total';
      } else {
        const prefix = columnOpts[columnNames[i]]?.prefix;
        col.innerText =
          (prefix || '') +
          formatNumber(
            data
              .map(c => c[i])
              .reduce((acc, cur) => {
                return (acc || 0) + (cur || 0);
              })
          );
      }
    }

    dataGridContainer.appendChild(dataGridFooter);
  }

I hope this illustrates what I mean by this enhancement and helps someone currently in a similar scenario.

from highcharts.

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.