- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在制作一张关于一天吃的水果的图表,在下面的示例中效果很好。
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"hideCredits": true,
"fixedColumnWidth": '10px',
"legend": {
"horizontalGap": 10,
"maxColumns": 1,
"position": "right",
"useGraphSettings": true,
"markerSize": 10
},
"dataProvider": [{
"creationDate": "04/09/18",
"Banana": 1,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "06/09/18",
"Banana": 10,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "08/09/18",
"Banana": 11,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "09/09/18",
"Banana": 1,
"Apple": 50,
"Grapes": 24
},
],
//"gridAboveGraphs": true,
"startDuration": 1,
"valueAxes": [{
"stackType": "regular",
"axisAlpha": 0.3,
"gridAlpha": 0,
"minimum": 0,
"maximum": 50,
"gridCount": 1
}],
"graphs": [{
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#47b012",
"lineColor": "#47b012",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Grapes Eaten",
"type": "column",
"color": "#000000",
"valueField": "Grapes",
"fixedColumnWidth": 25
}, {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#fff138",
"lineColor": "#fff138",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Banana Eaten",
"type": "column",
"color": "#000000",
"valueField": "Banana",
"fixedColumnWidth": 25
}, {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#dd111b",
"lineColor": "#dd111b",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Apples Eaten",
"type": "column",
"color": "#000000",
"valueField": "Apple",
"fixedColumnWidth": 25
}],
"categoryField": "creationDate",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0,
"position": "left",
"labelRotation": 80,
},
});
#chartdiv {
width: 100%;
height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
05-09-2018 和 07-09-2018 数据不在 dataprovider
字段中,因此我希望它自动填充到图表中。
最佳答案
您目前有一个将日期视为字符串(类别)的常规类别轴。
如果你想要一个真实的日期刻度,你需要通过设置 parseDates: true
使其成为基于日期的类别轴。在 categoryAxis
中。
但这还不够。
由于您的日期是非标准日期格式,因此您需要指示 amCharts 如何解析它们。那就是dataDateFormat
设置进来:
dataDateFormat: "DD/MM/YYYY"
最后,标签在基于日期的轴上遵循不同的规则。所以我们需要对代码进行一些调整,以便显示所有这些:
"categoryAxis": {
// ...
"autoGridCount": false,
"gridCount": 20
},
这是你的图表:
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"hideCredits": true,
"fixedColumnWidth": '10px',
"dataDateFormat": "DD/MM/YYYY",
"legend": {
"horizontalGap": 10,
"maxColumns": 1,
"position": "right",
"useGraphSettings": true,
"markerSize": 10
},
"dataProvider": [{
"creationDate": "04/09/18",
"Banana": 1,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "06/09/18",
"Banana": 10,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "08/09/18",
"Banana": 11,
"Apple": 13,
"Grapes": 24
},
{
"creationDate": "09/09/18",
"Banana": 1,
"Apple": 50,
"Grapes": 24
},
],
//"gridAboveGraphs": true,
"startDuration": 1,
"valueAxes": [{
"stackType": "regular",
"axisAlpha": 0.3,
"gridAlpha": 0,
"minimum": 0,
"maximum": 50,
"gridCount": 1
}],
"graphs": [{
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#47b012",
"lineColor": "#47b012",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Grapes Eaten",
"type": "column",
"color": "#000000",
"valueField": "Grapes",
"fixedColumnWidth": 25
}, {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#fff138",
"lineColor": "#fff138",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Banana Eaten",
"type": "column",
"color": "#000000",
"valueField": "Banana",
"fixedColumnWidth": 25
}, {
"balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
"fillColors": "#dd111b",
"lineColor": "#dd111b",
"fillAlphas": 0.8,
"labelText": "[[value]]",
"lineAlpha": 0.3,
"title": "Apples Eaten",
"type": "column",
"color": "#000000",
"valueField": "Apple",
"fixedColumnWidth": 25
}],
"categoryField": "creationDate",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"gridAlpha": 0,
"position": "left",
"labelRotation": 80,
"parseDates": true,
"autoGridCount": false,
"gridCount": 20
},
});
#chartdiv {
width: 100%;
height: 500px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
关于javascript - Amcharts 类别轴也显示空数据的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52288346/
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 9 个月前关闭。 Improve
我使用 partykit打包并遇到以下错误消息: Error in matrix(0, nrow = mi, ncol = nl) : invalid 'nrow' value (too large
我一直在尝试寻找一个量表或分类指标,为 VADER 情绪分析分配一些情感程度,而不仅仅是积极、消极或中性。如果有人可以分享他们的观点或资源来帮助按以下方式对 VADER 复合分数进行分类,我将非常感激
伙计们,我想自动循环..但我不知道是我放错了 while 还是循环错了? 我的数据库 标签:kt_barang kd_kategori | nama_kategori 1
我正在创建一个列出本地企业并按类别、子类别和关键字对它们进行分组的应用程序。以下是企业排序规则: 一个企业可以属于多个类别和子类别 一个企业可以有多个关键字 并非每个类别都有子类别,但有子类别的只有两
我有一系列单词 - 我的刺激 - 它们显示在屏幕上。然而,每个词都有另一个“条件”,即它们是类别 A、类别 B 或类别 C。这可能很简单,但我找不到答案并坚持下去。我的最终目标是在每次运行脚本时将类别
我正在使用 Laravel 5.5 和 MySql。如果不向 Services 表中添加 subCategoryID 列,我无法弄清楚如何将类别和子类别与服务相关联。 目前这是我的表结构 服务类别 i
我有两个部分/类别结构的链接表。 the section table structure id sec_title 1 section 1 2 section 2 the category str
我有一个类层次结构如下 @interface PTLDatasource : NSObject ... @interface PTLFetchedDatasource : PTLDatasource
我有一个 DataFrame df 一列,category 使用以下代码创建: import pandas as pd import random as rand from string import
我经常在多个类中设置获取请求以从核心数据(加上一些其他结果)中检索“allRecipes”或“lastModifiedDate”。 为此使用专门的类别 NSManagedObjectContext+R
可以在 Objective C 中创建类别之间的依赖关系吗?也在类别和它们的基类之间? 我知道在运行时应该没有区别,它们可能只是在编译时合并在一起。例如,假设我将 B 类分解为: B(base cla
这个问题在这里已经有了答案: 关闭 10 年前。
example img of a category selection by user 嘿,我正在尝试设置一个选择,用户必须选择一个类别和第二个类别,但我不知道如何获取他单击的信息。用户单击类别后,它
尝试将投资组合库添加到我正在制作的自定义 wp 主题中。我已经筋疲力尽地试图寻找甚至可以修改一些的解决方案和插件。我认为我在寻找解决方案时遇到的一个问题是我不完全确定哪些搜索词可以帮助我找到与我想要实
当我查看 Cocoa Touch API 时,我可以在同一个头文件中找到一些与类别一起声明的类,例如 @interface NSArray : NSObject @property (readonl
我的 log4j.properties 中有以下内容 log4j.rootLogger = debug, stdout, fileLog log4j.appender.stdout = org.apa
如果我在类中添加类别方法,比如NSXMLNode: @interface NSXMLNode (mycat) - (void)myFunc; @end NSXMLNode 的子类,例如 NSXMLEl
先说场景,wordpress的分类结构是这样的 Level 1: Top Level 2: -Nextme_1 Level 3: --Nextme_2 --Nextme_3 Leve
我有一个解析网络,现在我想浏览标签,或显示图表。我怎样才能得到图表?或者在树中导航。显示第一步然后其他等。并了解这棵树是如何 build 的。 import urllib from lxml impo
我是一名优秀的程序员,十分优秀!