无法在具有年度系列的图表上设置 min/max
Cannot set min/max on highcharts with yearly series
我以为我在 highcharts 上越来越好,但现在偶然发现了一个烦人的问题,我似乎无法设置 xAxis 由年组成的 xAxis 最小值和最大值。我在网上找不到类似的问题。
发生的情况是图表 xAxis 按预期绘制了年份...但是该系列完全消失并且图表上没有 yAxis。
这就是我设置 xAxis 选项的方式...有人知道为什么会这样吗?谢谢大家的宝贵时间。
xAxis: {
min: 2010,
max: 2030,
categories: [1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040]
},
series: [ (I have removed them from the example) ]
};
在您的情况下,选项 min
和 max
使用索引而不是数组的键。将 2010
替换为 30
,将 2030
替换为 50
,这应该有效!
或者使用函数indexOf
:
var yourArray = [1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040]
.
. //Define your highcharts options
.
xAxis: {
min: yourArray.indexOf(2010),
max: yourArray.indexOf(2030),
categories: yourArray
},
series: [ (I have removed them from the example) ]
};
我以为我在 highcharts 上越来越好,但现在偶然发现了一个烦人的问题,我似乎无法设置 xAxis 由年组成的 xAxis 最小值和最大值。我在网上找不到类似的问题。
发生的情况是图表 xAxis 按预期绘制了年份...但是该系列完全消失并且图表上没有 yAxis。
这就是我设置 xAxis 选项的方式...有人知道为什么会这样吗?谢谢大家的宝贵时间。
xAxis: {
min: 2010,
max: 2030,
categories: [1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040]
},
series: [ (I have removed them from the example) ]
};
在您的情况下,选项 min
和 max
使用索引而不是数组的键。将 2010
替换为 30
,将 2030
替换为 50
,这应该有效!
或者使用函数indexOf
:
var yourArray = [1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040]
.
. //Define your highcharts options
.
xAxis: {
min: yourArray.indexOf(2010),
max: yourArray.indexOf(2030),
categories: yourArray
},
series: [ (I have removed them from the example) ]
};