我正在尝试根据下拉选项更改线图中Y轴中的数据类型。例如,我有一个下拉,有狗和猫的数量作为Y轴值的选项。我知道我必须以某种方式更改图表中的 DataFieldY ,但我无法这样做。
<script type="text/javascript">
$(function () {
var newDataSource = [
{
"Cats": "Cats",
"Dogs": "Dogs",
"Dog Population": "30",
"Cat Population": 20,
"Year": 2015,
},
{
"Cats": "Cats",
"Dogs": "Dogs",
"Dog Population": "28",
"Cat Population": 22,
"Year": 2016,
}]
var RadHtmlChart1 = $find('<%=RadHtmlChart3.ClientID %>');
RadHtmlChart1.set_dataSource(newDataSource);
RadHtmlChart1.set_transitions(true);
RadHtmlChart1.repaint();
});
});
function OnClientClicked1() {
}
</script>
<div class="span4" id="lineChart">
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart3" Transitions="false" Width="700" Height="420">
<PlotArea>
<Series>
<telerik:LineSeries DataFieldY="Dog Population">
<Appearance>
<FillStyle BackgroundColor="Blue" />
</Appearance>
<MarkersAppearance MarkersType="Square" BackgroundColor="Blue" />
</telerik:LineSeries>
</Series>
<XAxis AxisCrossingValue="0" Color="Black" MajorTickType="Outside" MinorTickType="Outside"
Reversed="false" MinValue="0" MaxValue="90" Step="10" DataLabelsField="Year">
<LabelsAppearance DataFormatString="Year" RotationAngle="0" />
<MajorGridLines Color="#EFEFEF" Width="1" />
<MinorGridLines Color="#F7F7F7" Width="1" />
<TitleAppearance Position="Center" RotationAngle="0" Text="Year" />
</XAxis>
<YAxis AxisCrossingValue="0" Color="Black" MajorTickType="Outside"
Reversed="false" MinValue="0" Step="5">
<MajorGridLines Color="#EFEFEF" Width="1" />
<MinorGridLines Color="#F7F7F7" Width="1" />
<TitleAppearance Position="Center" RotationAngle="0" Text="Population"/>
</YAxis>
</PlotArea>
</telerik:RadHtmlChart>
</div>