GithubHelp home page GithubHelp logo

Comments (9)

raananzvi avatar raananzvi commented on July 18, 2024

You should follow the steps in this GitHub sample visual: https://github.com/Microsoft/PowerBI-visuals-sampleUsingExternalLibraries

from powerbi-visuals-tools.

SuperBobb avatar SuperBobb commented on July 18, 2024

Thank you for your answer.
I have followed this sample and have followed the article for referencing the d3 library (https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/Typings.md).
Those steps are working fine for those libraries however they are not helping me with the request module. Apparently its definition or implementation differs somehow.
Could you try to create a new visual project, do the same steps and use that library in the visual.ts file?
Or maybe you know another library that could help me with HTTP GET requests?

from powerbi-visuals-tools.

raananzvi avatar raananzvi commented on July 18, 2024

Several things:

  1. Did you include the request library in the tsconfig.json file?
  2. What API version are you targeting? Starting from API 1.2 you will not have D3 included in the IFRAME web page, and you will have to compile with D3 (add it to the tsconfig.json file)
  3. Even if you will be able to properly compile and run with this library, I'm not sure the browser or remote server will allow you to invoke the HTTP GET request. Currently, custom visuals are sandboxed in such a way that they don't have a defined origin (origin = null), this will cause most servers to reject your requests.

from powerbi-visuals-tools.

SuperBobb avatar SuperBobb commented on July 18, 2024
  1. Yes, here an extract from my tsconfic.json file:
  "files": [
    ".api/v1.2.0/PowerBI-visuals.d.ts",
    "typings/index.d.ts",
    "node_modules/request/request.js",
    "src/visual.ts"
  ]

And from my typings/index.d.ts as well:

/// <reference path="globals/form-data/index.d.ts" />
/// <reference path="globals/node/index.d.ts" />
/// <reference path="globals/request/index.d.ts" />

  1. The pbiviz -V gives me 1.2.1 version number.
    The problem is not with the D3 module but with the request one.
  2. OK, I was afraid of something like that.
    Still I would like to try it first.

from powerbi-visuals-tools.

SuperBobb avatar SuperBobb commented on July 18, 2024

I've made these screenshots to be sure that I explain everything properly.
Here is the screenshot from VS Code when the import statement is commented out.
You can see that there is no objects from the request library even if it is referenced in the index.d.ts file:
withoutimport
And here I uncommented the import statement. You can see that the default request function is there and referenced properly.
withimport
But those red squiggles mark those error messages I've mentioned in the first post here:

error TYPESCRIPT /src/visual.ts : (4,36) Cannot find name 'IVisual'.
error TYPESCRIPT /src/visual.ts : (8,30) Cannot find name 'VisualConstructorOptions'.
error TYPESCRIPT /src/visual.ts : (14,32) Cannot find name 'VisualUpdateOptions'.

The request's index.d.ts is there and looks fine:

// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/658d360c6a8611e76f7cc75c07fcd0f02055ffc4/request/request.d.ts
declare module 'request' {
    import stream = require('stream');
    import http = require('http');
    import https = require('https');
    import url = require('url');
    import fs = require('fs');
    import FormData = require('form-data');

    namespace request {
        export interface RequestAPI<TRequest extends Request,
            TOptions extends CoreOptions,
            TUriUrlOptions> {

            defaults(options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>;
            defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;

            (uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
            (uri: string, callback?: RequestCallback): TRequest;
            (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
............
    }
    var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>;
    export = request;
}

So how should I reference that library in my code?

from powerbi-visuals-tools.

AviSander avatar AviSander commented on July 18, 2024

Please try to see if this blog helps http://blog.jongallant.com/2016/09/how-to-create-power-bi-custom-visual.html

from powerbi-visuals-tools.

mmaitre314 avatar mmaitre314 commented on July 18, 2024

Cross-posting from https://github.com/Microsoft/PowerBI-visuals/issues/99 since that might be a better place: Power BI seems to break external libraries like vis.js that try to attach themselves to the window object.

from powerbi-visuals-tools.

sfuchickie avatar sfuchickie commented on July 18, 2024

@helen508light were you able to resolve this? I am running into something similar but cannot find a straightforward answer.

from powerbi-visuals-tools.

helen508light avatar helen508light commented on July 18, 2024

@sfuchickie what issue do you have?

from powerbi-visuals-tools.

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.