【问题标题】:Change label style of amCharts更改 amCharts 的标签样式
【发布时间】:2016-03-18 16:37:29
【问题描述】:

查看 amCharts 中的图像。我只想显示 Jan、Feb、Mar 等月份的短名称。而不是像 Jan 那样显示一年中的第一个月,而是显示 2016 年......请参阅突出显示的部分:

    AmCharts.makeChart("MonthlySaleChart",
            {
                "type": "serial",
                "categoryField": "date",
                "dataDateFormat": "YYYY-MM",
                "theme": "default",
                "categoryAxis": {
                    "minPeriod": "MM",
                    "parseDates": true
                },
                "chartCursor": {
                    "categoryBalloonDateFormat": "MMM YYYY"
                },
                "chartScrollbar": {},
                "trendLines": [],
                "graphs": [
                    {
                        "bullet": "round",
                        "id": "AmGraph-1",
                        "title": "This Year",
                        "valueField": "ThisMonth"
                    },
                    {
                        "bullet": "square",
                        "id": "AmGraph-2",
                        "title": "Last Year",
                        "valueField": "LastMonth"
                    }
                ],
                "guides": [],
                "valueAxes": [
                    {
                        "id": "ValueAxis-1",
                        "title": "Sales in Thousands (000)"
                    }
                ],
                "allLabels": [],
                "balloon": {},
                "legend": {
                    "useGraphSettings": true
                },
                "titles": [
                    {
                        "color": "#20C5AE",
                        "id": "Title-1",
                        "size": 15,
                        "text": "SALES By Month"
                    }
                ],
                "dataProvider": data
            }
        );

【问题讨论】:

  • 请提供更多信息,说明您目前所做的工作。您尝试过什么,结果如何?
  • 我只为char提供了三个值,一个是日期,另外两个是一些整数。我只想要系列中的月份短名称,但显示 2016 而不是“jan”。
  • 我的图表显示 1 月的第一个月,如 2016 或 2015 。我只是希望它显示简单的 jan 像 feb 或 mar
  • 您能发布您的代码吗?
  • 我贴了代码看看你能不能帮忙

标签: javascript charts amcharts


【解决方案1】:

要禁用显示年份而不是一月,请将categoryAxis 中的markPeriodChange 设置为false

"categoryAxis": {
  "minPeriod": "MM",
  "parseDates": true,
  "markPeriodChange": false
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多