отрицательные значения оси сбивают график - PullRequest
0 голосов
/ 20 декабря 2018

Я пытался создать диаграмму с некоторыми значениями на оси, которые отображаются в ожидаемом порядке с учетом предоставленных данных (отмечены красным) enter image description here

, но меня смущает то, что япредоставить отрицательные значения (те же значения, только что добавленные -), он просто показывает 0 на оси enter image description here

есть ли возможность создать такое же поведение, как у меня на положительных значениях, когда они предоставляются данные, поэтому он не дает сбой при предоставлении значений?

$(function() {
  var chart = new Highcharts.Chart(


  {
  "meta": {
    "drilldownEnabled": false
  },
  "chart": {
  renderTo:"container",
    "additionalData": {
      "dateTime": false,
      "datetype": "string",
      "cliccable": true,
      "drillable": false,
      "drillableChart": false,
      "isCockpit": true,
      "categoryColumn": "product_name",
      "categoryGroupBy": "",
      "categoryGroupByNamens": "",
      "categoryName": "product_name",
      "categoryOrderColumn": "",
      "categoryOrderType": "",
      "categoryStacked": "",
      "categoryStackedType": ""
    },
    "zoomType": "xy",
    "panning": true,
    "type": "column",
    "options3d": {
      "enabled": false,
      "alpha": 25,
      "beta": 15,
      "depth": 50,
      "viewDistance": 25
    },
    "backgroundColor": "#FFFFFF",
    "heightDimType": "pixels",
    "widthDimType": "pixels",
    "plotBackgroundColor": null,
    "plotBorderWidth": null,
    "plotShadow": false,
    "borderColor": "#FFFFFF",
    "style": {
      "backgroundColor": "#FFFFFF",
      "fontFamily": "",
      "fontWeight": "",
      "fontSize": ""
    },
    "events": {}
  },
  "colors": [
    "#7cb5ec",
    "#434348",
    "#90ed7d",
    "#f7a35c",
    "#8085e9",
    "#f15c80",
    "#e4d354",
    "#2b908f",
    "#f45b5b",
    "#91e8e1"
  ],
  "title": {
    "text": "",
    "style": {
      "align": "",
      "color": "",
      "fontFamily": "",
      "fontSize": "",
      "fontWeight": ""
    }
  },
  "legend": {
    "itemDistance": 0,
    "symbolPadding": 25,
    "enabled": false
  },
  "xAxis": [
    {
      "plotBands": [
        {
          "label": {
            "text": "",
            "align": "center"
          },
          "color": "",
          "from": 0,
          "to": 0
        }
      ],
      "plotLines": [
        {
          "label": {
            "text": "",
            "align": "center"
          },
          "color": "",
          "dashStyle": "",
          "value": 0,
          "width": 0
        }
      ],
      "type": "category",
      "id": 0,
      "title": {
        "customTitle": false,
        "text": "product_name",
        "style": {}
      },
      "labels": {
        "style": {
          "color": "",
          "fontFamily": "",
          "fontSize": "",
          "fontWeight": ""
        },
        "align": ""
      }
    }
  ],
  "yAxis": [
    {
      "plotBands": [
        {
          "label": {
            "text": "",
            "align": "center"
          },
          "color": "",
          "from": 0,
          "to": 0
        }
      ],
      "plotLines": [
        {
          "label": {
            "text": "",
            "align": "center"
          },
          "color": "",
          "dashStyle": "",
          "value": 0,
          "width": 0
        }
      ],
      "min": 0,
      "title": {
        "text": "store_sales",
        "customTitle": false,
        "style": {
          "color": "",
          "fontFamily": "",
          "fontWeight": "",
          "fontSize": ""
        }
      },
      "labels": {
        "style": {
          "color": "",
          "fontFamily": "",
          "fontSize": "",
          "fontWeight": ""
        },
        "align": ""
      },
      "gridLineDashStyle": "$convertedTypeline",
      "minorGridLineDashStyle": "$convertedMinorTpeline"
    }
  ],
  "series": [
    {
      "name": "store_sales",
      "dataLabels": {
        "style": {
          "color": "",
          "fontFamily": "",
          "fontWeight": "",
          "fontSize": "",
          "fontStyle": ""
        },
        "enabled": true,
        "labelFormat": "{y:,.2f}"
      },
      "data": [
        {
          "drilldown": false,
          "y": -6.36,
          "name": "ADJ Rosy Sunglasses",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -9.55,
          "name": "Akron City Map",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -12.55,
          "name": "American Beef Bologna",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -7.35,
          "name": "American Chicken Hot Dogs",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -12.19,
          "name": "American Cole Slaw",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -6.68,
          "name": "American Corned Beef",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -8.57,
          "name": "American Foot-Long Hot Dogs",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -6,
          "name": "American Low Fat Bologna",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -7.94,
          "name": "American Low Fat Cole Slaw",
          "datetype": "string"
        },
        {
          "drilldown": false,
          "y": -6.49,
          "name": "American Pimento Loaf",
          "datetype": "string"
        }
      ],
      "selected": true,
      "tooltip": {
        "valueDecimals": 2,
        "scaleFactor": "empty",
        "ttBackColor": "#FCFFC5"
      },
      "yAxis": 0
    }
  ],
  "tooltip": {
    "borderWidth": 0,
    "borderRadius": 0,
    "followTouchMove": false,
    "followPointer": true,
    "useHTML": true,
    "backgroundColor": null,
    "style": {
      "padding": 0
    }
  },
  "lang": {
    "noData": ""
  },
  "noData": {
    "style": {
      "fontFamily": "",
      "fontSize": "",
      "color": ""
    },
    "position": {
      "align": "center",
      "verticalAlign": "middle"
    }
  },
  "credits": {
    "enabled": false
  },
  "plotOptions": {
    "line": {
      "marker": {
        "symbol": "circle",
        "lineWidth": 2
      }
    },
    "series": {
      "events": {},
      "showCheckbox": true,
      "cursor": "pointer",
      "point": {
        "events": {}
      },
      "dataLabels": {
        "allowOverlap": true
      },
      "turboThreshold": 2000
    }
  }
}





  );
});

здесь фрагмент отрицательный (с ошибкой) http://jsfiddle.net/JeLrb/532 здесь тот же фрагмент только с положительным (как значения оси должны бытьотображается) http://jsfiddle.net/JeLrb/533/

Кто-нибудь знает решение для этого?Спасибо!

Ответы [ 2 ]

0 голосов
/ 21 декабря 2018

Удалите yAxis: "min: 0", и это создаст отрицательную метку yAxis для вас.Пожалуйста, проверьте

 "yAxis": [
{
  /*"min": 0,  remove this */
  "title": {
    "text": "store_sales",
    "customTitle": false,
    "style": {
      "color": "",
      "fontFamily": "",
      "fontWeight": "",
      "fontSize": ""
    }
  }
}

]

http://jsfiddle.net/98b0dkLj

0 голосов
/ 20 декабря 2018

Если вы измените "yAxis": "min": с 0 на что-то вроде -20, это будет работать.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...