Series.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. define("dojox/charting/Series", ["dojo/_base/lang", "dojo/_base/declare", "./Element"],
  2. function(lang, declare, Element){
  3. /*=====
  4. dojox.charting.__SeriesCtorArgs = function(plot){
  5. // summary:
  6. // An optional arguments object that can be used in the Series constructor.
  7. // plot: String?
  8. // The plot (by name) that this series belongs to.
  9. this.plot = plot;
  10. }
  11. var Element = dojox.charting.Element;
  12. =====*/
  13. return declare("dojox.charting.Series", Element, {
  14. // summary:
  15. // An object representing a series of data for plotting on a chart.
  16. constructor: function(chart, data, kwArgs){
  17. // summary:
  18. // Create a new data series object for use within charting.
  19. // chart: dojox.charting.Chart
  20. // The chart that this series belongs to.
  21. // data: Array|Object:
  22. // The array of data points (either numbers or objects) that
  23. // represents the data to be drawn. Or it can be an object. In
  24. // the latter case, it should have a property "data" (an array),
  25. // destroy(), and setSeriesObject().
  26. // kwArgs: dojox.charting.__SeriesCtorArgs?
  27. // An optional keyword arguments object to set details for this series.
  28. lang.mixin(this, kwArgs);
  29. if(typeof this.plot != "string"){ this.plot = "default"; }
  30. this.update(data);
  31. },
  32. clear: function(){
  33. // summary:
  34. // Clear the calculated additional parameters set on this series.
  35. this.dyn = {};
  36. },
  37. update: function(data){
  38. // summary:
  39. // Set data and make this object dirty, so it can be redrawn.
  40. // data: Array|Object:
  41. // The array of data points (either numbers or objects) that
  42. // represents the data to be drawn. Or it can be an object. In
  43. // the latter case, it should have a property "data" (an array),
  44. // destroy(), and setSeriesObject().
  45. if(lang.isArray(data)){
  46. this.data = data;
  47. }else{
  48. this.source = data;
  49. this.data = this.source.data;
  50. if(this.source.setSeriesObject){
  51. this.source.setSeriesObject(this);
  52. }
  53. }
  54. this.dirty = true;
  55. this.clear();
  56. }
  57. });
  58. });