简体   繁体   English

ExtJS 4图表-更改轴,系列和存储

[英]ExtJS 4 Chart - Change axes, series, and store

I have a chart that will show energy generation over a day, month, or year, depending on the user's selection. 我有一张图表,将根据用户的选择显示一天,一个月或一年内的发电量。 To do this on a single chart, I need to be able to change the axes, series, and store when a button is clicked. 要在单个图表上执行此操作,我需要能够在单击按钮时更改轴,系列和存储。 I have managed to get this working, except I have the issue of the old data, series, and axes are still showing, and the new ones are just being laid on top. 我设法完成了这项工作,除了旧数据,系列和轴仍在显示的问题,而新数据只是放在最上面。 Is there a way to clear or refresh/redraw a chart? 有什么方法可以清除或刷新/重绘图表? Or should I just split this into 3 charts, and hide/show the charts on button click? 还是我应该将其分为3个图表,然后单击按钮隐藏/显示这些图表?

Here is my current code for setting axes, series and store on the fly. 这是我当前用于设置轴,系列和即时存储的代码。

        chart.axes.clear();
        chart.axes.addAll(dailyAxes);
        chart.series.clear();
        chart.series.addAll(dailySeries);
        chart.bindStore(Ext.data.StoreManager.lookup('dailyEnergy'));

A little late, but what's missing is this: 有点晚了,但是缺少的是:

chart.surface.removeAll()

This isn't ideal, as you may get a flash of empty space as it destroys the previous elements, but it does avoid the hangover of old data. 这是不理想的,因为它会破坏先前的元素,但可能会闪现出空白,但它确实避免了旧数据的困扰。

i dont know what type of chart or what is dailyAxes 我不知道什么类型的图表或什么是DailyAxes

but i assume u want to change axes properties..hee is an example on how to do it: 但我假设您想更改轴属性。.hee是有关如何执行此操作的示例:

Ext.getCmp('chartid').axes.get("gauge").maximum =  100;

then u need to redraw the chart after ur done: 然后您需要在完成后重新绘制图表:

Ext.getCmp('chartid').redraw();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM