- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 API highcharts 按国家/地区显示我网站的访问者数量。我通过 mysql 接收数据,我在 php 中有这个表:
<?php $data = Array ( [0] => Array ( [name] => DE [y] => 1 ) [1] => Array ( [name] => FR [y] => 3 ) [2] => Array ( [name] => US [y] => 1 ) [3] => Array ( [name] => XX [y] => 1 ) ); ?>
然后在我的 php 文件的底部,我把我的 js:
var g_donnes = '<?php echo json_encode($data); ?>';
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares in January, 2018'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
data: g_donnes
}]
});
所以当我创建一个 console.log (g_donnes) 时,我有这个表 [{"name":"DE","y":1},{"name":"FR","y ":3},{"name":"US","y":1},{"name":"XX","y":1}]
,但是缺点 g_donnes 没有被数据级别的代码:g_donnes
谢谢你的帮助
最佳答案
你不需要引号:
var g_donnes = <?php echo json_encode($data); ?>;
使用引号,您的 g_donnes
是字符串,而不是您的代码所需的数组。
关于javascript - 动态数据处理之Highcharts问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56339881/
解释 我的应用程序基本上使用带有代表建筑物的多边形叠加层的 map View ,以及注释。为此,它导入了一个名为 Annotation 的自定义类,该类在点击注释时处理弹出详细信息,这意味着它存储建筑
我有一个数据处理问题,我想计算两支球队在不同比赛中的进球数差异。数据如下所示: matchId teamId eventSec 1 2799331 6718 443.55984
如下所示: ? 1
我想知道 cocoa 是否有默认的数据存储方式。如果是,那是什么?我的意思是 Rails 默认使用 sqlite... 此外,我正在寻找有关如何使用它的教程...例如获取数据并将其显示到 ListVi
我正在使用 HTML5 创建在线游戏。我将使用 JSON 字符串通过 Websockets 通信数据,因此典型的字符串将包含被调用的操作以及随之而来的数据: {action: "chat", user
我需要按特定列对一组 csv 行进行分组,并对每个组进行一些处理。 JavaRDD lines = sc.textFile ("somefile
我有一个情况: 基本上有 3 个模块,分别命名为“A”、“B”、“C”。每个模块都涉及多线程。 模块“A”获取高速数据(20ms)并发送。模块“B”的一个线程启动。 模块“B”提取相关数据并执行一些位
我正在处理有关城镇和城镇内区域的 MySQL 数据库中的一些数据。 数据库看起来像这样 ID | NAME 1 | Manchester 2 | Manchester/North 3 | Man
当我注册用户时,我得到一个状态代码 200 和一个 token :“”返回 JSON。如果用户已经存在,那么我会得到状态代码 200 和 html 响应而不是 JSON。我应该如何处理这个问题。提前致
我有一个应用程序,我从网络上下载大量资源,并对每个资源进行一些处理。我不希望这项工作发生在主线程上,但它非常轻量级且优先级较低,因此所有这些工作都可以真正发生在同一个共享工作线程上。这似乎是一件好事,
我目前正在与一家小公司合作,该公司将其所有应用程序数据存储在 AWS Redshift 集群中。我的任务是对该 Redshift 集群中的数据进行一些数据处理和机器学习。 我需要做的第一个任务是根据一
简介 有些 post 的请求参数是 json 格式的,这个前面发送post 请求里面提到过,需要导入 json模块处理。现在企业公司一般常见的接口因为json数据容易处理,所以绝大多数返回数据也是
1.数组的处理: 1.1 数组的创建和初始化: 1.arrary()函数创建数组,默认情况下0元素是数组的第一个元素, count()和sizeof()函数获得数
我正在尝试将 CKEditor 与 AngularJS 结合使用,用于具有数据绑定(bind)的 WYSIWYG 编辑器,一切似乎都运行良好。极端的可配置性对我们的需求匹配有很大帮助。 我们现在面临表
我正在对负样本和正样本进行文本二元分类任务,我想包括以下所有内容: 处理数据..(例如标记化) 特征选择,例如 Chi2 应用随机投影,因为我有一个大型稀疏矩阵(n_samples:974,n_fea
数据与我在 Pandas 系列: data = ["1. stock1 (1991)", "3. stock13 (1993)", "5. stock19 (1999)", "89. stock
1.字符串的定义与显示 定义:通过””,''来标志 显示:echo()和print(),但print()具有返回值值,1,而echo()没有,但echo比print()要快,
1.正则表达式基础知识 含义:由普通字符和(a-z)和一些特殊字符组成的字符串模式 功能:有效性验证。 替换文本。 从一个字符串提取一个子字符串。&n
我想知道是否可以在我的 Cost Explorer 中发现这个成本背后的资源,按使用类型分组我可以看到它是数据处理字节,但我不知道哪个资源会消耗这个数量数据的。知道如何在 CloudWatch 上发现
我有一个 Json 字符串。我想从该 Json 字符串中获取值。 这是我的 json 字符串{“纬度”:“22.5712854”},{“经度”:“88.4266847”} 我只需要使用 TSQL 查询
我是一名优秀的程序员,十分优秀!