2017-07-18 3 views
1

私は次のコードセグメントをsheild UIに持っています。Sheild UIのX軸のTicksRepeatをカスタマイズするjQuery

<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をカスタマイズする必要があります。たとえば、私は2つの日付値、from dateto dateを持っています。その差が1年である場合、TicksRepeatは12、すなわち数ヶ月でなければならない。差が1ヶ月であれば、TicksRepeatは日数でなければなりません。

jQueryはトリックですか? jQueryを初めて使用しています。誰かがこれを達成するために助けてくださいできますか?

答えて

1

ticksRepeatオプションを使用してグラフAPIを使用してグラフを更新することができます。ターゲットのChart要素を選択して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 }}); 

詳細なチャートAPI Documentationも他の設定可能なオプションでチェックアウトすることができます。

希望すると便利です。

関連する問題