Требуется Js AMD - зависимости не узнают себя - PullRequest
0 голосов
/ 30 ноября 2018

Я разрабатываю расширение для Qlik Sense, используя angular.В этом случае мне нужны d3.min.js и d3.pie.js.D3pie нужен d3 для правильной работы.Я импортирую зависимости с этим кодом

define([
  "qlik",
  "./assets/properties",
  "./assets/initial-properties",
  "text!./assets/template.ng.html",
  "./assets/d3.min",
  "./assets/d3.pie"
], function(qlik, props, initial, template, d3, d3pie) {
  "use strict";

  return {
    initialProperties: initial,
    definition: props,
    template: template,
    paint: paint,
    support: {
      exportData: false,
      snapshot: true,
      export: true
    }
  };

  function paint($element, layout) {
    console.log(d3);
    console.log(d3.arc);
    // Empty container when paint is fired
    $element.empty();
    // Chart object width
    var width = $element.width();
    // Chart object height
    var height = $element.height();
    // Create Container
    $element.append(
      $("<div />")
        .attr("id", layout.qInfo.qId)
        .width(width)
        .height(height)
    );

    $("#" + layout.qInfo.qId)
      .append("<div/>")
      .attr("id", "pieChart")
      .attr("width", width)
      .attr("height", height);

    var pie = new d3pie("pieChart", {
      header: {
        title: {
          fontSize: 24,
          font: "open sans"
        },
        subtitle: {
          color: "#999999",
          fontSize: 12,
          font: "open sans"
        },
        titleSubtitlePadding: 9
      },
      footer: {
        color: "#999999",
        fontSize: 10,
        font: "open sans",
        location: "bottom-left"
      },
      size: {
        canvasWidth: 590,
        pieInnerRadius: "1%",
        pieOuterRadius: "100%"
      },
      data: {
        sortOrder: "value-desc",
        content: [
          {
            label: "Stella",
            value: 157618,
            color: "#7d9058"
          },
          {
            label: "Budweiser",
            value: 114384,
            color: "#b94444"
          },
          {
            label: "Ritas",
            value: 95002,
            color: "#7c37c0"
          },
          {
            label: "Busch",
            value: 78327,
            color: "#cc9fb1"
          },
          {
            label: "Bud Light",
            value: 67706,
            color: "#e65414"
          },
          {
            label: "Corona",
            value: 36344,
            color: "#8b6834"
          },
          {
            label: "Natural Light",
            value: 32170,
            color: "#248838"
          }
        ]
      },
      labels: {
        outer: {
          pieDistance: 32
        },
        inner: {
          hideWhenLessThanPercentage: 3
        },
        mainLabel: {
          fontSize: 11
        },
        percentage: {
          color: "#ffffff",
          decimalPlaces: 0
        },
        value: {
          color: "#adadad",
          fontSize: 11
        },
        lines: {
          enabled: true
        },
        truncation: {
          enabled: true
        }
      },
      tooltips: {
        enabled: true,
        type: "placeholder",
        string: "{label}: {value}, {percentage}%,  Vs Sply: 40%",
        styles: {
          backgroundOpacity: 0.69,
          fontSize: 12
        }
      },
      effects: {
        pullOutSegmentOnClick: {
          effect: "linear",
          speed: 400,
          size: 8
        }
      },
      misc: {
        gradient: {
          enabled: true,
          percentage: 100
        }
      }
    });

    pie;

  }
});

D3 и D3 pie зарегистрированы правильно.Но когда я запускаю приложение, я получаю эту ошибку:

enter image description here

Кажется, что d3pie не находит d3.min.Что я делаю не так?

...