1

我正在通过 amcharts 开发一个图表,我希望它选择某些范围,因为我在我的地图上处理超过 6000 个 x 值..我试图在我的地图上使用 zoomToCategory 控件但是当我使用它时地图没有出现.. :( ..任何原因???以下是我的代码。:)

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>

        <head>

            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>amCharts examples</title>
            <link rel="stylesheet" href="http://localhost/amcharts/images/style.css" type="text/css">
            <script src="http://localhost/amcharts/amcharts.js" type="text/javascript"></script>         
            <script type="text/javascript">

                var chart;

                var chartData = JSON.parse('<%=sjson%>');// [{ "Ip": "0", "Count": "10" }, { "Ip": "1", "Count": "11" }, { "Ip": "2", "Count": "12" }, { "Ip": "3", "Count": "13" }, { "Ip": "4", "Count": "14" }, { "Ip": "5", "Count": "15" }, { "Ip": "6", "Count": "16" }, { "Ip": "7", "Count": "17" }, { "Ip": "8", "Count": "18" }, { "Ip": "9", "Count": "19"}];



                AmCharts.ready(function () {
                    // SERIAL CHART
                    chart = new AmCharts.AmSerialChart();
                    chart.dataProvider = chartData;
                    chart.categoryField = "Ip";
                    chart.startDuration = 1;

                    // AXES
                    // category
                    var categoryAxis = chart.categoryAxis;
                    categoryAxis.labelRotation = 90;
                    categoryAxis.gridPosition = "Count";

                    // value
                    // in case you don't want to change default settings of value axis,
                    // you don't need to create it, as one value axis is created automatically.

                    // GRAPH
                    var graph = new AmCharts.AmGraph();
                    graph.valueField = "Count";
                    graph.balloonText = "[[category]]: [[value]]";
                    graph.type = "column";
                    graph.lineAlpha = 0;
                    graph.fillAlphas = 0.8;

                    graph.zoomToCategoryValues("1", "10");
                    chart.addGraph(graph);

                    chart.write("chartdiv");
                });
            </script>

        </head>

        <body>
            <div id="chartdiv" style="width: 100%; height: 400px;"></div>
        </body>

    </html>

请帮我解决这个问题……在这个 grpah 上钻取 x 轴非常重要,因为它显示了大量数据……非常感谢:)

4

2 回答 2

2

这适用于任何使用柱形图遇到此问题的人。我花了 2 天时间,但对于某些人来说,这可能是一个非常明显的答案,所以在这里,这段代码将 amcchart 滚动条添加到 javascript 中的柱形图中。:)

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>

        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>amCharts examples</title>
            <link rel="stylesheet" href="style.css" type="text/css">
            <script src="../amcharts/amcharts.js" type="text/javascript"></script>         
            <script type="text/javascript">
                var chart;

                var chartData = [{"Ip":"0","Count":"10"},{"Ip":"1","Count":"11"},{"Ip":"2","Count":"12"},{"Ip":"3","Count":"13"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"},{"Ip":"4","Count":"14"},{"Ip":"5","Count":"15"},{"Ip":"6","Count":"16"},{"Ip":"7","Count":"17"},{"Ip":"8","Count":"18"},{"Ip":"9","Count":"19"}];



                AmCharts.ready(function () {
                    // SERIAL CHART
                    chart = new AmCharts.AmSerialChart();
                    chart.dataProvider = chartData;
                    chart.categoryField = "Ip";
                    chart.startDuration = 1;
                    chart.pathToImages = "http://localhost/images/";
                    //scrollbar definition
                    var chartScrollbar = new AmCharts.ChartScrollbar();

                    // AXES
                    // category
                    var categoryAxis = chart.categoryAxis;
                    //categoryAxis.labelRotation = 90;
                    categoryAxis.gridPosition = "Count";

                    // value
                    // in case you don't want to change default settings of value axis,
                    // you don't need to create it, as one value axis is created automatically.

                    // GRAPH
                    var graph = new AmCharts.AmGraph();
                    graph.valueField = "Count";
                    graph.balloonText = "[[category]]: [[value]]";
                    graph.type = "column";
                    graph.lineAlpha = 0;
                    graph.fillAlphas = 0.8;

                    //add scrollbar to graph
                    chartScrollbar.graph = graph;
                    chartScrollbar.scrollbarHeight = 40;
                    chartScrollbar.color = "#FFFFFF";
                    chartScrollbar.autoGridCount = true;
                    chart.addChartScrollbar(chartScrollbar);

                    chart.addGraph(graph);

                    chart.write("chartdiv");
                });
            </script>
        </head>

        <body>
            <div id="chartdiv" style="width: 100%; height: 400px;"></div>
        </body>

    </html>

希望能帮助到你 :)

于 2012-09-04T04:54:08.473 回答
2

graph 没有 zoomToCategoryValues 方法,只有 chart 有。而且你不能在图表初始化之前调用这个方法。

您应该监听“init”或“dataUpdated”事件并调用一个方法来进行缩放:

// this line shoulf go to AmCharts.ready function:
chart.addListener("dataUpdated", zoomChart);

// this is a method which will be called after the event is fired:
function zoomChart() {
     chart.zoomToCategoryValues("1", "10");
}
于 2012-09-04T05:45:30.560 回答