GithubHelp home page GithubHelp logo

isabella232 / d3-dashboard-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adobe/d3-dashboard-api

0.0 0.0 0.0 1.28 MB

JavaScript Library(NPM module) that wraps Adobe Analytics APIs and D3 charts

License: Apache License 2.0

JavaScript 92.52% CSS 4.81% HTML 2.67%

d3-dashboard-api's Introduction

d3-dashboard-api

JavaScript library that bundles Adobe analytics APIs and D3 visualizations. You can use this module to create custom visualizations with Adobe Analytics data on third-party websites in a matter of minutes.

Goals

Make it easier for developers to create their own visualization using D3 and Adobe Analytics APIs. This library should allow developers to easily create their own D3 charts with Adobe Analytics data with just an API call.

Index

  1. Steps to run
  2. Code Sample
  3. Charts Available
  4. Contributing
  5. License

Steps to run:

  1. On Adobe I/O Console create an Integration
  2. Use Cleint ID and Cleint Secret to generate an access token. Postman (OAuth2.0) or Adobe I/O Playground can be used.
    Anlytics Scopes: openid,AdobeID,read_organizations,additional_info.projectedProductContext,additional_info.job_function
  3. Load d3-dashboard-api.min.js from this repo in your html file.
  4. Create three variables - query, file, company, accessToken:
    • query : dictionary of dictionaries with chart details(html div id and type of chart) and api configuration(filters, dimensions etc.)
    • company : org's name for e.g. adobe-io-solutions-demo
    • accessToken : Token from step 1
      Refer sample code
  5. In the HTML file add D3 CDN and create the divs with IDs mentioned in query.chart.id
  6. Call dashboard(query, company, accessToken); - this will fetch data and create a svg div with visualization, just add it to the div you want.

Charts Available:

  1. Bubble Chart - type : 'bubble' (name to be mentioned in query.chart.type)
  2. Bar Chart - type : 'bar'
  3. Pie Chart - type : 'pie'

Code Sample

sample.js

 const accessToken = '< ACCESS_TOKEN >'; //token from step 1
 const company = '< company_name >'
 
 const query = {
     'chart' : {
         'type' : 'bubble',              // Type of D3 chart
         'id' : 'bubblechart-container'  //HTML div to which chart needs to be rendered
     },
     'api' : {                                   // https://github.com/AdobeDocs/analytics-2.0-apis
                                                 
             'rsid' : ' report-suite-ID',
             'end-point' : '/reports/ranked',
             'dimension' : 'variables/browser',
             'globalFilters' : [
                 {
                 'dateRange' : '2009-06-01T00:00/2018-08-21T00:00',
                 'type' : 'dateRange'
                 }
             ],
             'metrics' : [
                 {
                 'columnId' : 'visits',
                 'id' : 'metrics/visits'
                 }
             ]       
     }
 };

 const html = dashboard(query, company, accessToken);
 html.then((res) => {
     $('#' + query.chart.id).append(res);
 });

sample.html

<html>
  <head>
    <meta charset="utf-8"/>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://d3js.org/d3.v4.min.js"></script>
    <script src="./d3-dashboard-api.min.js"></script>
    <script src="./sample.js"></script>
  </head>
  <body>
    <p>Welcome to new Dashbaord</p>
    <div id="bubblechart-container"></div>
    <div id="barchart-container"></div>
    <div id="piechart-container"></div>
  </body>
 </html>

Contributing:

If you would like to contribute to this project in the form of filing issues, fixing bugs and creating pull requests. Please follow this document. Please also check our code of conduct

Steps to add a chart:

  1. Clone this repository
  2. Run npm install
  3. Add a chart class(in a js file) to /public/js/.
  4. Associate your chart class name with it's repective file name inside chartMapping dictionary /configs/mapping.js
  5. Build it

Steps to add an Adobe Anlytics API:

  1. Clone this repository
  2. Run npm install
  3. Add an API class(in a js file) to /utils/.
  4. Associate your API class name with it's repective file name inside apiMapping dictionary /configs/mapping.js
  5. Build it

Build It:

  1. Run command npm run build

License:

Licensed under Apache-2

d3-dashboard-api's People

Contributors

abhishekchandran avatar

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.