javascript - 如何在高位图表中更改输入位置?
问题描述
这是我在 highcharts 中图表的默认样式:我想更改输入的位置,我使用的图表来自https://www.highcharts.com/站点,
我想从左到右更改输入并从从右到左,从和到文本
我想成为这样的形象:
我怎样才能做到这一点?
解决方案
常规的 Highcharts API 选项无法更改,但对核心代码进行一些更改就可以了。
在Highcharts.RangeSelector.prototype.render我们需要切换触发rangeSelector.drawInput函数的顺序:
if (inputEnabled !== false) {
rangeSelector.div = div = createElement('div', null, {
position: 'relative',
height: 0,
zIndex: inputsZIndex
});
container.parentNode.insertBefore(div, container);
// Create the group to keep the inputs
rangeSelector.inputGroup = inputGroup =
renderer.g('input-group').add(group);
inputGroup.offset = 0;
rangeSelector.drawInput('max');
rangeSelector.drawInput('min');
}
在Highcharts.RangeSelector.prototype.drawInput我在这里做了一些样式/创建更改:
// Create an SVG label that shows updated date ranges and and records
// click events that bring in the HTML input.
this[name + 'DateBox'] = dateBox = renderer.label('', inputGroup.offset)
.addClass('highcharts-range-input')
.attr({
padding: 2,
width: options.inputBoxWidth || 90,
height: options.inputBoxHeight || 17,
'text-align': 'center'
})
.on('click', function() {
// If it is already focused, the onfocus event doesn't fire
// (#3713)
rangeSelector.showInput(name);
rangeSelector[name + 'Input'].focus();
});
// Create the text label
this[name + 'Label'] = label = renderer.label(
lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'],
this.inputGroup.offset
)
.addClass('highcharts-range-label')
.attr({
padding: 2,
paddingLeft: 100
})
.add(inputGroup);
inputGroup.offset += label.width - 85;
推荐阅读
- sql - 返回整个会话符合条件的 ID
- jsgrid - JSGrid 项目选择与 DB
- python - 是否可以从 Python 脚本设置 bash/linux 终端环境变量?
- sass - 如何覆盖strapis“主按钮”
- django - 访问 CheckboxSelectMultiple 复选框的属性
- vba - 通过在VBA中乘以-1来更改列中值的符号
- html - stockquote api,无法打印文本颜色
- jquery - 调用 ajax 到另一个 ajax
- xml - 如何在 SQL/PLSQL (Oracle) 中读取 XMLTYPE 数据但命名空间
- scala - 如何在为类型实现的 scala 宏中使用 ClassTag