使用Highcharts创建一维图表

时间:2015-10-28 06:03:37

标签: javascript highcharts

如何创建像HBR网站上使用的一维散点图:

1D scatter plot

当我在浏览HBR的JS文件后试图复制它时,我得到以下内容:

Extra line on the y axis

我需要消除y轴上的第二个网格线。

以下是我正在使用的JS代码:

$(function () {

    $('#highchart').highcharts({
        credits: {
            enabled: !1
        },
        chart: {
            type: "scatter",
            height: 140,
            width: 580,
            renderTo: "chart"
        },
        title: {
            style: {
                color: "#000",
                fontFamily: "Helvetica, Arial, sans-serif",
                fontSize: "12px",
                fontWeight: "bold",
                textTransform: "uppercase",
                whiteSpace: "normal"
            },
            text: "Test"
        },
        legend: {
            text: null,
            useHTML: !0,
            x: 20,
            align: "center",
            itemStyle: {
                color: "#000",
                fontFamily: "Stationery, Helvetica, Arial, sans-serif",
                fontSize: "8px",
                fontWeight: "normal",
                lineHeight: "10px",
                textTransform: "uppercase"
            },
            borderWidth: 1,
            enabled: !0,
            itemMarginTop: 0,
            itemMarginBottom: 0,
            layout: "horizontal",
            verticalAlign: "bottom"
        },
        xAxis: {
            title: {
                text: null,

            },
            min: 0,
            max: 5,
            labels: {
                enabled: !1
            },
            tickLength: 0,
            lineWidth: 0
        },
        yAxis: [{
            max: 0,
            min : 0,
            minRange :0.1,
            maxPadding: .01,
            lineWidth: 0,
            tickWidth: 2,
            tickLength: 6,
            labels: {
                y: 3
            },

            title: {
                text: "Opportunity for<br/>development",
                rotation: 0,
                align: "middle",
                offset: 50,
                style: {
                    color: "#000",
                    fontFamily: "Stationery, Helvetica, Arial, sans-serif",
                    fontSize: "10px",
                    fontWeight: "normal",
                    lineHeight: "10px",
                    textTransform: "uppercase"
                }

            },
            labels: {

                enabled: !1
            },
            tickWidth: 0,
            tickLength: 0,
            maxPadding: 0,
            padding: 30,
            gridLineWidth: 2
        }, {
            title: {
                text: "Strength",
                rotation: 0,
                align: "middle",
                offset: 50
            },
            opposite: !0
        }],
        plotOptions: {
            scatter: {
                events: {
                    legendItemClick: function () {
                        return !1
                    }
                },
                marker: {
                    radius: 8,
                    states: {
                        hover: {
                            enabled: !0
                        }
                    },
                    symbol: "circle"
                },
                tooltip: {
                    fontFamily: "Stationery, Helvetica, Arial, sans-serif",
                    headerFormat: "<b>{series.name}</b><br>",
                    pointFormat: "{point.x} out of 25"
                }
            }
        },
        series: [{
            name: "How you scored",
            color: "#4cb6e8",
            data: [[3, 0]],
        }, {
            name: "Average",
            color: "#b20303",
            data: [[4, 0]],
            zIndex: 8,
            marker: {
                symbol: "diamond"
            }

        }],

    });
});

1 个答案:

答案 0 :(得分:0)

JSONArray array= new JSONArray(resultdata); for(int i=0;i<array.length();i++) { carid.add(jsonObject.getString("Id")); carlogo.add(jsonObject.getString("CarImage")); carname.add(jsonObject.getString("CarType")); prize.add(jsonObject.getString("Price")); availibility.add(jsonObject.getString("CarAvailable"));} 对象使用tickInterval选项,其值大于(yAxis - max)值

min

JSFiddle demo