如何动态更改线性仪表融合图表上的指针位置

时间:2011-09-20 13:36:36

标签: asp.net xml ajax fusioncharts

我有线性guage融合图表,指针在图表上方,指针值保持动态更新,我试图根据xml文件中的值定位指针,但我面临的问题是每次指针获取重新定位,整个图形刷新,我的要求是只重新定位指针,不应刷新完整的图表,任何人可以帮助,实现此功能,我试图按照以下链接{{3}中显示的示例}

1 个答案:

答案 0 :(得分:2)

您可以随时使用JavaScript或实时数据流更新线性量表的指针值。

比如说您使用以下XML创建了图表:

<chart lowerLimit='0' upperLimit='100' lowerLimitDisplay='Bad' upperLimitDisplay='Good' palette='1' numberSuffix='%' chartRightMargin='20'>
   <colorRange>
      <color minValue='0' maxValue='75' code='FF654F' label='Bad'/>
      <color minValue='75' maxValue='90' code='F6BD0F' label='Moderate'/>
      <color minValue='90' maxValue='100' code='8BBA00' label='Good'/>
   </colorRange>
   <pointers>
      <pointer value='92' />
   </pointers>
</chart>

并使用以下JavaScript呈现图表:

var myChart = new FusionCharts("Charts/HLinearGauge.swf", "myChartId", "450", "120", "0", "1");
myChart.setDataURL("Data/Linear3.xml");
myChart.render("chartdiv");

现在,您可以使用以下JavaScript代码更新此图表:

getChartFromId("myChartId").setData(1, 20);

还有其他API函数,如:setDataForId(Id,value)或feedData(updateDataQueryString)

例如,

getChartFromId("myChartId").setDataForId("p1", 40) ;// this requires the pointer to be set with an id which needs to be provided here as the first parameter 

getChartFromId("myChartId").feedData("&value=90") ;

您也可以使用它来仅更新现有仪表的数据。

欲了解更多信息,请阅读: http://www.fusioncharts.com/widgets/docs/Contents/Linear_JSPAPI.html

详细了解如何使用服务器端实时数据流来更新仪表的数据: http://www.fusioncharts.com/widgets/docs/Contents/Linear_RealTime.html

为此,您需要创建一个dat提供程序页面,其输出将是查询字符串格式的单行字符串,如:&value=30