Series.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.charting.Series"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.Series"] = true;
  8. dojo.provide("dojox.charting.Series");
  9. dojo.require("dojox.charting.Element");
  10. /*=====
  11. dojox.charting.__SeriesCtorArgs = function(plot){
  12. // summary:
  13. // An optional arguments object that can be used in the Series constructor.
  14. // plot: String?
  15. // The plot (by name) that this series belongs to.
  16. this.plot = plot;
  17. }
  18. =====*/
  19. dojo.declare("dojox.charting.Series", dojox.charting.Element, {
  20. // summary:
  21. // An object representing a series of data for plotting on a chart.
  22. constructor: function(chart, data, kwArgs){
  23. // summary:
  24. // Create a new data series object for use within charting.
  25. // chart: dojox.charting.Chart2D
  26. // The chart that this series belongs to.
  27. // data: Array|Object:
  28. // The array of data points (either numbers or objects) that
  29. // represents the data to be drawn. Or it can be an object. In
  30. // the latter case, it should have a property "data" (an array),
  31. // destroy(), and setSeriesObject().
  32. // kwArgs: dojox.charting.__SeriesCtorArgs?
  33. // An optional keyword arguments object to set details for this series.
  34. dojo.mixin(this, kwArgs);
  35. if(typeof this.plot != "string"){ this.plot = "default"; }
  36. this.update(data);
  37. },
  38. clear: function(){
  39. // summary:
  40. // Clear the calculated additional parameters set on this series.
  41. this.dyn = {};
  42. },
  43. update: function(data){
  44. // summary:
  45. // Set data and make this object dirty, so it can be redrawn.
  46. // data: Array|Object:
  47. // The array of data points (either numbers or objects) that
  48. // represents the data to be drawn. Or it can be an object. In
  49. // the latter case, it should have a property "data" (an array),
  50. // destroy(), and setSeriesObject().
  51. if(dojo.isArray(data)){
  52. this.data = data;
  53. }else{
  54. this.source = data;
  55. this.data = this.source.data;
  56. if(this.source.setSeriesObject){
  57. this.source.setSeriesObject(this);
  58. }
  59. }
  60. this.dirty = true;
  61. this.clear();
  62. }
  63. });
  64. }