amCharts3序列图可以设置特定的x轴吗?

时间:2019-06-21 09:58:24

标签: javascript amcharts

我正在创建一个amCharts3序列图,以显示24小时内(午夜至午夜)的每小时产量,预测水平和目标水平。每小时和预测数据每30分钟记录一次,然后将在图表上显示为项目符号。目标数据是静态值,由图表上的一条线表示

我的图表代码是

                        "type": "serial",
                        "backgroundAlpha": 1,
                        "plotAreaFillAlphas": 1,
                        "autoMargin": true,
                        "autoMarginOffset": 30,
                        "autoDisplay": true,
                        "marginRight": 50,
                        "color": "#000000",
                        "plotAreaFillColors": scope.config.plotAreaFillColor,
                        "creditsPosition": "bottom-right",
                        "titles": createArrayOfChartTitles(),
                        "fontSize": 11,
                        "pathToImages": "Scripts/app/editor/symbols/ext/images/",
                        "categoryAxis": {
                            "parseDates": true,
                            "minPeriod": "ss",
                            "axisAlpha": 1,
                            "axisColor": "black",
                            "gridAlpha": 0.1,
                            "autoWrap": true,
                            "gridThickness": 2,
                            "title": "Time, hrs"
                        },
                        "chartScrollbar": {
                            "enabled": false
                        },
                        "legend": {
                            "enabled": true,
                            "useGraphSettings": true,
                            "color": "#000000",
                            "labelText": "[[title]]",
                        },
                        "valueAxes": [
                            {
                                "title": "Temperature",
                                "inside": false,
                                "axisAlpha": 1,
                                "axisColor": "black",
                                "fillAlpha": 0.05,
                                "gridAlpha": 0.1,
                                "gridThickness": 2
                            }
                        ],
                        "graphs": [
                            {
                                "id": "g1",
                                "title": graph1Label,
                                "type": "line",
                                "bullet": "square",
                                "lineThickness": 0,
                                "bulletColor": "#0094FF",
                                "balloonColor": "#0094FF",
                                "balloonText": "[[timestamp]]<br />[[value1]]", 
                                "valueField": "value1"
                            },
                            {
                                "id": "g2",
                                "title": graph2Label,
                                "type": "line",
                                "bullet": "round",
                                "lineThickness": 0,
                                "bulletColor": "#FF8000",
                                "balloonColor": "#FF8000",
                                "balloonText": "[[timestamp]]<br />[[value2]]", 
                                "valueField": "value2"
                            },
                            {
                                "id": "g3",
                                "title": graph3Label,
                                "type": "line",
                                "lineThickness": 1,
                                "lineColor": "#FF0000",
                                "balloonColor": "#FF0000",
                                "balloonText": "[[timestamp]]<br />[[value3]]", 
                                "valueField": "value3"
                            }
                        ],
                        "dataProvider": dataArray,
                        "categoryField": "timestamp",
                        "chartCursor": { 
                            "cursorColor": "gray",
                            "valueLineBalloonEnabled": true,
                            "valueLineEnabled": true,
                            "valueZoomable": true,
                            "categoryBalloonDateFormat": "D/MM/YYYY L:NN:SS A"
                        },
                        "zoomOutButtonImage": ""
                    }

数据正确显示,但是我试图将x轴范围设置为特定的起点和终点。

我希望图表显示的x轴设置为从午夜到午夜。即使是上午10点,我也希望图表显示整个24小时的时间范围。

当前图表显示从午夜到当前查看时间的数据。例如午夜至上午10点。

我已经添加了图像,用于显示当前的外观以及所需的结果。

Current Display

Desired Display

1 个答案:

答案 0 :(得分:0)

我能够使用amCharts提供的日期填充插件来解决此问题。

Date padding plugin