option.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. export default {
  2. methods: {
  3. getOptionTitle () {
  4. return {
  5. show: this.validData(this.option.titleShow, false),
  6. text: this.option.title,
  7. subtext: this.option.subtext || '',
  8. textStyle: {
  9. color: this.option.titleColor || '#333',
  10. fontSize: this.option.titleFontSize || 16
  11. },
  12. left: this.option.titlePosition || 'auto',
  13. subtextStyle: {
  14. color: this.option.subTitleColor || '#aaa',
  15. fontSize: this.option.subTitleFontSize || 14
  16. }
  17. }
  18. },
  19. getOptionGrid () {
  20. return {
  21. height: Number(this.option.split) * 10,
  22. left: this.option.gridX || 20,
  23. top: this.option.gridY || 60,
  24. right: this.option.gridX2 || 20,
  25. bottom: this.option.gridY2 || 60
  26. }
  27. },
  28. getOptionTip (prop = {}) {
  29. return {
  30. ...{
  31. show: this.validData(this.option.tipShow, true),
  32. formatter: this.formatter && (() => {
  33. return params => this.formatter(params, this.dataChart)
  34. })(),
  35. backgroundColor: this.option.tipBackgroundColor || "rgba(0,0,0,0.5)",
  36. textStyle: {
  37. fontSize: this.option.tipFontSize || 20,
  38. color: this.option.tipColor || "#fff"
  39. }
  40. },
  41. ...prop
  42. }
  43. },
  44. getOptionLegend (data) {
  45. return {
  46. type: 'scroll',
  47. show: this.validData(this.option.legend, false),
  48. orient: this.option.legendOrient || "horizontal",
  49. x: this.option.legendPosition || "right",
  50. textStyle: {
  51. fontSize: this.option.legendFontSize || 12
  52. },
  53. data: (data || this.dataChart.series || this.dataChart).map((ele, index) => {
  54. return {
  55. name: ele.name,
  56. textStyle: this.getHasProp(!this.switchTheme, {
  57. color: this.getColor(index, true)
  58. })
  59. };
  60. })
  61. }
  62. },
  63. getOptionLabel (prop = {}) {
  64. return {
  65. ...{
  66. show: this.validData(this.option.labelShow, false),
  67. formatter: this.labelFormatter && (() => {
  68. return params => this.labelFormatter(params, this.dataChart)
  69. })(),
  70. textStyle: {
  71. fontSize: this.option.labelShowFontSize || 14,
  72. color: this.option.labelShowColor || "inherit",
  73. fontWeight: this.option.labelShowFontWeight || 500
  74. },
  75. ...prop
  76. }
  77. }
  78. },
  79. }
  80. }