Javascript jQuery在Sheild UI中自定义X轴的重复标记
我在sheild UI中有以下代码段Javascript jQuery在Sheild UI中自定义X轴的重复标记,javascript,jquery,charts,shieldui,Javascript,Jquery,Charts,Shieldui,我在sheild UI中有以下代码段 <Axes> <shield:ChartAxisY> <Title Text="Portfolio Value($)"></Title> </shield:ChartAxisY> <shield:ChartAxisX TicksRepeat="10" CategoricalValues=""> <Title Text="Po
<Axes>
<shield:ChartAxisY>
<Title Text="Portfolio Value($)"></Title>
</shield:ChartAxisY>
<shield:ChartAxisX TicksRepeat="10" CategoricalValues="">
<Title Text="Portfolio Date"></Title>
<AxisTickText></AxisTickText>
</shield:ChartAxisX>
</Axes>
我想要的是TicksRepeat可以定制。例如,我有两个日期值,from date
和to date
。如果差值为一年,则TicksRepeat应为12,即以月为单位。如果差值为一个月,则TicksRepeat应以天为单位。等等
jQuery会起作用吗?
我不熟悉jQuery。有人能帮忙吗?您可以使用Javascript的
ticksRepeat
选项使用图表API刷新图表。只需选择目标图表元素即可执行API方法。
下面是实现所需功能的代码
var chart = $('#chart').swidget(); // your target sheild chart selector
var tickRepeat; // to store the tick repeat value
// Your if condition to check the date difference
// Based on the diffrence set the value of `tickRepeat`
if(<your-year-conditions>){
tickRepeat = 12;
}else{
tickRepeat = <your-days-value>; // replace with your days diff
}
// Call the refresh method on the Chart Object to rerender the chart
// With your new tickRepeat on X Axis as below.
chart.refresh({axisX: {ticksRepeat: tickRepeat }});
var chart=$('#chart').swidget();//您的目标sheild图表选择器
var tickRepeat;//存储勾号重复值的步骤
//您的if条件检查日期差异
//根据差异设置'tickRepeat'的值`
if(){
重复次数=12次;
}否则{
tickRepeat=;//替换为您的天数差异
}
//调用图表对象上的refresh方法以重新渲染图表
//在X轴上重复新的滴答声,如下所示。
刷新({axisX:{ticksRepeat:tickRepeat}});
您可以签出详细的图表以及其他可配置的选项
希望这有帮助