Highcharts如何仅在x轴的值大于0时绘制
Highcharts how to only plot if x axis is having value greater than 0?
伙计们,我有一个简单的高图表,显示问题的数量和每天解决的问题的数量。图表的开始日期是当前日期的-30天。因此,它将始终显示每30天的数据。
现在我要做的是动态地从x轴上的数据大于0的位置开始绘制图表。
例如,如果29天的问题/解决计数为0,在第30天的问题计数增加到1,我想从第30天开始图表,以此类推。
这是我的图表代码
$('#performance-cart').highcharts({
chart: {
type: 'area', backgroundColor: '#f5f7f7', style: { fontFamily: 'Roboto, Sans-serif', color: '#aeafb1' },
animation: {
duration: 1500,
easing: 'easeOutBounce'
}
},
xAxis: {
type: 'datetime',
labels: { style: { color: '#aeafb1' } }
},
yAxis: {
min: 0, max: maxVal, tickInterval: 10, gridLineColor: '#ebeded', gridLineWidth: 1,
title: { text: '' }, lineWidth: 0, labels: { align: 'right', style: { color: '#aeafb1' } }
},
title: { text: '' },
tooltip: {
useHTML: true, headerFormat: '<h3 style="color:#ffffff;font-weight:300;padding: 3px 12px;">{point.y:,.1f}</br>',
backgroundColor: '#515757', pointFormat: 'Issues</h3>'//$('#performanceColumnChart').data('tooltip')
},
legend: {
itemStyle: { color: '#838589' }, symbolWidth: 12, symbolHeight: 5, itemWidth: 80, symbolRadius: 0,
itemMarginBottom: 10, backgroundColor: '#f5f7f7', verticalAlign: 'top', borderWidth: 0, x: -498, y: 10
},
plotOptions: {
area: {
fillOpacity: 0.2, cursor: 'pointer', marker: {
symbol: 'circle', fillColor: '#FFFFFF', lineWidth: 2, lineColor: null,
allowPointSelect: true
}
},
line: {
fillOpacity: 0.2, cursor: 'pointer', marker: {
symbol: 'circle', fillColor: '#FFFFFF', lineWidth: 2, lineColor: null,
allowPointSelect: true
}
},
column: {
fillOpacity: 0.2, cursor: 'pointer', marker: {
symbol: 'circle', fillColor: '#FFFFFF', lineWidth: 2, lineColor: null,
allowPointSelect: true
}
},
series: {
pointStart: myDateVariable,
pointInterval: 24 * 3600 * 1000 // one day
}
},
series: [{
name: 'Issues', color: '#ff3806',
data: myIssueData,
marker: { states: { hover: { fillColor: '#ff3806', lineColor: '#ffffff', lineWidth: 2 } } }
}, {
name: 'Resolved', color: '#1da9dd',
data: myResolvedData,
marker: { states: { hover: { fillColor: '#1da9dd', lineColor: '#ffffff', lineWidth: 2 } } }
}]
});
这种方法可能吗?如果是的话,我想要一些建议。我搜索了高排名的官方文件,但没有得到任何帮助。
最简单的方法是预处理您的数据,使myIssueData
满足您的要求。您没有说明使用什么来生成数据,因此答案将取决于您的数据源。对于基于sql的,您可以查询最近的非0发行日期,然后使用该日期作为查询的起点。Psuedo-code:
DECLARE @startDate AS datetime
SELECT @startDate = MAX(date)
FROM myIssuesTable
WHERE issueCountColumn > 0
SELECT date, issueCountColumn
FROM myIssuesTable
WHERE date >= @startDate
ORDER BY date ASC
第二个查询的结果成为您的myIssueData
。这并不包括问题数超过30天大于0的情况,但在这种情况下,您可以跳过此查询,并使用从今天起30天前的date
直接查询。
相关文章:
- 使图像在单击时展开到不大于浏览器
- 在选择更改时显示大于/小于的隐藏字段集
- 当天数大于月份的天数时,javascript日期会创建奇怪的日期
- 当数组达到大于 x 的数字时,继续新行
- 当模态有时大于屏幕时,我如何水平/垂直居中模式弹出窗口
- 当屏幕 CSS 像素比大于 1 时,在不同的浏览器上获取相同的 window.screen.height 和 windo
- 当输入类型文本小于 0 或大于 24 时,如何禁用输入类型按钮
- 仅当窗口大于 X 时才加载脚本
- 当文本值大于$40时为模态-jQuery
- 只有当JavaScript中的子字符串长度大于x时,才从子字符串中删除字符
- 当value大于1时,执行此操作
- 当窗口大小大于800时,运行Jquery函数
- 当数字i大于50000时,如何才能显示数组值?javascript
- 仅当包含字符串长度大于X时才替换
- Highcharts如何仅在x轴的值大于0时绘制
- Jquery模态窗口只在输入值长度大于2时显示
- 当笔画宽度大于1时,IE中的SVG笔画动画
- 如何在文本区域的文本长度大于52时增加其行数?
- 使用这个代码,我是如何做到的,当分数差大于等等时,它就说明了什么
- 当字段值长度大于 0 时显示按钮重置