npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@domoinc/legend-connector

v0.1.0

Published

LegendConnector - Domo Widget

Downloads

18

Readme

How to add the legend to a widget using the legend-connector

  1. Widget.js

    At top of the code, add

    var Legend = require('@domoinc/legend');
    var legendConnector = require('@domoinc/legend-connector');

    After the _Chart.mergeConfig, add

    _Chart.mergeConfig(legendConnector.getLegendConfigs(daTheme2));

    At the end of the transform, add

    legendConnector.initializeLegend(_Chart, Legend, _Chart._colorScale);
    setLegendTriggers();
    legendConnector.drawLegend(_Chart, validData, _Chart.a('Series'));

    The triggers may need modifications to ensure the right data is being passed. The object that the legend returns is {series: name}

    function setLegendTriggers() {
      if (_Chart.c('showLegend').value) {
        _Chart.on('dispatch:mouseover', function(obj) {
          _Chart._legend.trigger('external:mouseover', obj);
        });
    
        _Chart.on('dispatch:mouseout', function() {
          _Chart._legend.trigger('external:mouseout');
        });
    
        _Chart._legend.on('dispatch:mouseover', function(obj) {
          _Chart.trigger('external:mouseover', obj.series);
        });
    
        _Chart._legend.on('dispatch:mouseout', function() {
          _Chart.trigger('external:mouseout');
        });
      }
    }
  2. DomoWidget.js

    At the top of the code, add

    var legendConnector;
    if (typeof require !== 'undefined') {
      legendConnector = require('@domoinc/legend-connector');
    } else {
      legendConnector = window.LegendConnector;
    }

    After bbox is defined and before the container is removed, add

    var legendPosition = legendConnector.getLegendPosition(container); //gets the client rect for the legend chartbounds

    After the dataName is set and before return widget, add

    legendConnector.setLegendPosition(widget, legendPosition); //update value for legend position, sets a default if undefined
    widget.prepareForArtboard = legendConnector.prepareForArtboard(widget, widget.a('Series'));
    legendConnector.pullFromArtboard(AutoWidgets, widget, widget.a('Series')); //update legend configs changed on artboard
  3. CreateWidget.js

    At the top of the code, add

    var legendConnector;
    if (typeof require !== 'undefined') {
      legendConnector = require('@domoinc/legend-connector');
    } else {
      legendConnector = window.LegendConnector;
    }

    Before chart.draw(data) and after chart is initialized, add

    //set default legend position
    legendConnector.setLegendPosition(chart);
  4. auto.html

    To allow the legend connector to work locally, before the src/DomoWidget.js and after the dist/bundle.js script tags, add

    <script type="text/javascript" src="node_modules/@domoinc/legend-connector/dist/bundle.js"></script>
  5. index.html

    To allow the legend connector to work locally, before the src/DomoWidget.js and after the dist/bundle.js script tags, add

    <script type="text/javascript" src="node_modules/@domoinc/legend-connector/dist/bundle.js"></script>
  6. webpack.config.js

    In the externals object, add

    '@domoinc/legend': {
      root: 'Legend',
      commonjs: '@domoinc/legend',
      commonjs2: '@domoinc/legend',
      amd: 'legend'
    },
    '@domoinc/legend-connector': {
      root: 'LegendConnector',
      commonjs: '@domoinc/legend-connector',
      commonjs2: '@domoinc/legend-connector',
      amd: 'legend-connector'
    }
  7. package.json

    Run these commands to get the dependencies and package.json updated:

  npm install @domoinc/legend -S
  npm install @domoinc/legend-connector -S
  ```

  ```
  "@domoinc/legend": "^6.0.11",
  "@domoinc/legend-connector": "0.0.27",
  ```