【问题标题】:Add dc.js to cumulocity web application将 dc.js 添加到 cumulocity Web 应用程序
【发布时间】:2017-03-08 00:24:52
【问题描述】:

我们想在我们的 cumulocity Web 应用程序中使用 dc.js,但我们在尝试这样做时发现了一个问题。该应用程序可以独立运行,但是当我们想在累积中使用它时,它就不行了。

这是我们的独立代码:

<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>

<title>QWHealth Experiment</title>

<style type="text/css"></style>

<style>
h4 span {
  font-size:14px;
  font-weight:normal;
  }

h2 {
  float: right;
}
h2 span {
  font-size:14px;
  font-weight:normal;
  }
</style>
<script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js' type='text/javascript'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/dc/2.0.0/dc.min.js' type='text/javascript'></script>

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js' type='text/javascript'></script>
<script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js' type='text/javascript'></script>

<link href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
<link href='http://cdnjs.cloudflare.com/ajax/libs/dc/2.0.0/dc.min.css' rel='stylesheet' type='text/css'>

</head>
.....

这是独立的结果:

然后我们尝试在 Cumulocity 中运行它,因为 cumulocity 已经有 d3.js、bootstrap 等。我们只是修改脚本加载。

<head>
<meta charset='utf-8'>

<title>QWHealth Experiment</title>

<style type="text/css"></style>

<style>
h4 span {
  font-size:14px;
  font-weight:normal;
  }

h2 {
  float: right;
}
h2 span {
  font-size:14px;
  font-weight:normal;
  }
</style>

<script src='https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/dc/2.0.0/dc.min.js' type='text/javascript'></script>
<link href='http://cdnjs.cloudflare.com/ajax/libs/dc/2.0.0/dc.min.css' rel='stylesheet' type='text/css'>

</head>

这是使用 cli 命令的结果:c8y server

但是,我们看到 dc.js 加载成功,那么,我缺少什么?

提前致谢!

编辑:

link to the index-cumulocity.html

link to the index.html which is the standalone app

【问题讨论】:

  • 您的应用程序是否有机会在某个地方可用?

标签: javascript html cumulocity


【解决方案1】:

看起来第一次访问dc 变量是在它完全加载之前进行的。也许您需要检查加载文件的顺序(在您的屏幕截图中,我看不到您如何加载自己的代码)。

【讨论】:

  • Pawel,请看我的编辑!我添加了代码,以便您了解我使用 dc 调用的方式和位置。
  • 如何在 Cumulocity 应用程序中包含 index-cumulocity.html?您是否知道您可以将您的独立应用程序上传为 *.zip 文件 (cumulocity.com/guides/users-guide/administration/…)。然后它将由 Cumulocity 平台提供,但包含您自己的所有文件。如果您想让您的应用程序成为您的自定义 Cumulocity 应用程序的一部分,您需要开发一个插件 (cumulocity.com/guides/web/introduction)。
  • Pawel,它是一个基于插件的应用程序。可以给你的邮件吗?我可以把包含所有文件的文件夹发给你。
  • 当然,您可以将其发送至 pawel.rynarzewski@cumulocity.com。
猜你喜欢
  • 2012-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多