init.uts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. import { ChartOptions, ChartOptionsLegend, ChartOptionsSeries, ChartOptionsSeriesData, ChartOptionsSubTitle, ChartOptionsTitle, ChartOptionsXAxis, ChartOptionsYAxis, ChartOptionsYAxisData, ChartOptionsMapSeriesProperties, ChartOptionsMapSeriesPropertiesParent, ChartOptionsMapSeriesGeometry } from "./type";
  2. import { extraInit } from './extrainit.uts'
  3. export function seriesDataInit(e : UTSJSONObject) : ChartOptionsSeriesData {
  4. const series_data = new ChartOptionsSeriesData()
  5. if (e['name'] != null) series_data.name = e.getString('name')!
  6. if (e['value'] != null) series_data.value = e.getNumber('value')!
  7. if (e['color'] != null) series_data.color = e.getString('color')!
  8. if (e['labelText'] != null) series_data.labelText = e.getString('labelText')!
  9. if (e['labelShow'] != null) series_data.labelShow = e.getBoolean('labelShow')!
  10. if (e['centerText'] != null) series_data.centerText = e.getString('centerText')!
  11. if (e['centerTextSize'] != null) series_data.centerTextSize = e.getNumber('centerTextSize')!
  12. if (e['centerTextColor'] != null) series_data.centerTextColor = e.getString('centerTextColor')!
  13. return series_data
  14. }
  15. export function seriesInit(e : UTSJSONObject, type : string = '') : ChartOptionsSeries {
  16. const series = new ChartOptionsSeries()
  17. if (e['index'] != null) series.index = e.getNumber('index')!
  18. if (e['name'] != null) series.name = e.getString('name')!
  19. if (e['legendText'] != null) series.legendText = e.getString('legendText')!
  20. if (e['show'] != null) series.show = e.getBoolean('show')!
  21. if (e['color'] != null) series.color = e.getString('color')!
  22. if (e['fillOpacity'] != null) series.fillOpacity = e.getNumber('fillOpacity')!
  23. if (e['textColor'] != null) series.textColor = e.getString('textColor')!
  24. if (e['textSize'] != null) series.textSize = e.getNumber('textSize')!
  25. if (e['textOffset'] != null) series.textOffset = e.getNumber('textOffset')!
  26. if (e['linearIndex'] != null) series.linearIndex = e.getNumber('linearIndex')!
  27. if (e['type'] != null) series.type = e.getString('type')!
  28. if (e['disableLegend'] != null) series.disableLegend = e.getBoolean('disableLegend')!
  29. if (e['connectNulls'] != null) series.connectNulls = e.getBoolean('connectNulls')!
  30. if (e['setShadow'] != null) series.setShadow = e.getArray('setShadow') as string[]
  31. if (e['linearColor'] != null) series.linearColor = e.getArray('linearColor') as string[][]
  32. if (e['style'] != null) series.style = e.getString('style')!
  33. if (e['addPoint'] != null) series.addPoint = e.getBoolean('addPoint')!
  34. if (e['lineType'] != null) series.lineType = e.getString('lineType')!
  35. if (e['dashLength'] != null) series.dashLength = e.getNumber('dashLength')!
  36. if (e['pointShape'] != null) series.pointShape = e.getString('pointShape')!
  37. if (e['legendShape'] != null) series.legendShape = e.getString('legendShape')!
  38. if (e['formatter'] != null) series.formatter = e.getAny('formatter')!
  39. if (e['format'] != null) series.format = e.getString('format')!
  40. if (e['rotate'] != null) series.rotate = e.getBoolean('rotate')!
  41. if (e['seriesMA'] != null) {
  42. const seriesmas : ChartOptionsSeries[] = []
  43. const data = e.getArray('seriesMA') as UTSJSONObject[]
  44. data.forEach((item : UTSJSONObject) => {
  45. seriesmas.push(seriesInit(item))
  46. })
  47. series.seriesMA = seriesmas
  48. }
  49. if (e['data'] != null) {
  50. if (type == 'scatter' || type == 'bubble' || type == 'candle') {
  51. series.dataArr = e.getArray('data') as number[][]
  52. } else {
  53. const seriesdata : ChartOptionsSeriesData[] = []
  54. const data = e.getArray('data') as UTSJSONObject[]
  55. data.forEach((item : UTSJSONObject) => {
  56. seriesdata.push(seriesDataInit(item))
  57. })
  58. series.data = seriesdata
  59. }
  60. }
  61. if (type == 'map') {
  62. if (e['properties'] != null) {
  63. series.properties = mapSeriesPropertiesInit(e.getJSON('properties')!)
  64. }
  65. if (e['geometry'] != null) {
  66. series.geometry = mapSeriesGeometryInit(e.getJSON('geometry')!)
  67. }
  68. }
  69. return series
  70. }
  71. //x轴数据解析
  72. export function xAxisInit(e : UTSJSONObject) : ChartOptionsXAxis {
  73. const xAxis : ChartOptionsXAxis = new ChartOptionsXAxis();
  74. if (e['disabled'] != null) xAxis.disabled = e.getBoolean('disabled')!;
  75. if (e['axisLine'] != null) xAxis.axisLine = e.getBoolean('axisLine')!;
  76. if (e['axisLineColor'] != null) xAxis.axisLineColor = e.getString('axisLineColor')!;
  77. if (e['calibration'] != null) xAxis.calibration = e.getBoolean('calibration')!;
  78. if (e['fontColor'] != null) xAxis.fontColor = e.getString('fontColor')!;
  79. if (e['fontSize'] != null) xAxis.fontSize = e.getNumber('fontSize')!;
  80. if (e['lineHeight'] != null) xAxis.lineHeight = e.getNumber('lineHeight')!;
  81. if (e['marginTop'] != null) xAxis.marginTop = e.getNumber('marginTop')!;
  82. if (e['rotateLabel'] != null) xAxis.rotateLabel = e.getBoolean('rotateLabel')!;
  83. if (e['rotateAngle'] != null) xAxis.rotateAngle = e.getNumber('rotateAngle')!;
  84. if (e['labelCount'] != null) xAxis.labelCount = e.getNumber('labelCount')!;
  85. if (e['itemCount'] != null) xAxis.itemCount = e.getNumber('itemCount')!;
  86. if (e['boundaryGap'] != null) xAxis.boundaryGap = e.getString('boundaryGap') as 'center' | 'justify';
  87. if (e['disableGrid'] != null) xAxis.disableGrid = e.getBoolean('disableGrid')!;
  88. if (e['splitNumber'] != null) xAxis.splitNumber = e.getNumber('splitNumber')!;
  89. if (e['gridColor'] != null) xAxis.gridColor = e.getString('gridColor')!;
  90. if (e['gridType'] != null) xAxis.gridType = e.getString('gridType') as 'solid' | 'dash';
  91. if (e['dashLength'] != null) xAxis.dashLength = e.getNumber('dashLength')!;
  92. if (e['gridEval'] != null) xAxis.gridEval = e.getNumber('gridEval')!;
  93. if (e['scrollShow'] != null) xAxis.scrollShow = e.getBoolean('scrollShow')!;
  94. if (e['scrollAlign'] != null) xAxis.scrollAlign = e.getString('scrollAlign') as 'left' | 'right';
  95. if (e['scrollColor'] != null) xAxis.scrollColor = e.getString('scrollColor')!;
  96. if (e['scrollBackgroundColor'] != null) xAxis.scrollBackgroundColor = e.getString('scrollBackgroundColor')!;
  97. if (e['min'] != null) xAxis.min = e.getNumber('min')!;
  98. if (e['max'] != null) xAxis.max = e.getNumber('max')!;
  99. if (e['title'] != null) xAxis.title = e.getString('title')!;
  100. if (e['titleFontSize'] != null) xAxis.titleFontSize = e.getNumber('titleFontSize')!;
  101. if (e['titleOffsetY'] != null) xAxis.titleOffsetY = e.getNumber('titleOffsetY')!;
  102. if (e['titleOffsetX'] != null) xAxis.titleOffsetX = e.getNumber('titleOffsetX')!;
  103. if (e['titleFontColor'] != null) xAxis.titleFontColor = e.getString('titleFontColor')!;
  104. if (e['formatter'] != null) xAxis.formatter = e.getAny('formatter')!;
  105. if (e['format'] != null) xAxis.format = e.getString('format')!;
  106. if (e['data'] != null) {
  107. const xAxis_data : ChartOptionsYAxisData[] = []
  108. const data = e.getArray('data') as UTSJSONObject[]
  109. data.forEach((item : UTSJSONObject) => {
  110. xAxis_data.push(yAxisDataInit(item))
  111. })
  112. xAxis.data = xAxis_data
  113. }
  114. return xAxis;
  115. }
  116. export function yAxisDataInit(e : UTSJSONObject) : ChartOptionsYAxisData {
  117. const yAxis_data : ChartOptionsYAxisData = new ChartOptionsYAxisData();
  118. if (e['type'] != null) yAxis_data.type = e.getString('type')!;
  119. if (e['position'] != null) yAxis_data.position = e.getString('position') as 'left' | 'right' | 'center';
  120. if (e['disabled'] != null) yAxis_data.disabled = e.getBoolean('disabled')!;
  121. if (e['axisLine'] != null) yAxis_data.axisLine = e.getBoolean('axisLine')!;
  122. if (e['axisLineColor'] != null) yAxis_data.axisLineColor = e.getString('axisLineColor')!;
  123. if (e['calibration'] != null) yAxis_data.calibration = e.getBoolean('calibration')!;
  124. if (e['fontColor'] != null) yAxis_data.fontColor = e.getString('fontColor')!;
  125. if (e['fontSize'] != null) yAxis_data.fontSize = e.getNumber('fontSize')!;
  126. if (e['textAlign'] != null) yAxis_data.textAlign = e.getString('textAlign') as 'left' | 'right' | 'center';
  127. if (e['title'] != null) yAxis_data.title = e.getString('title')!;
  128. if (e['titleFontSize'] != null) yAxis_data.titleFontSize = e.getNumber('titleFontSize')!;
  129. if (e['titleOffsetY'] != null) yAxis_data.titleOffsetY = e.getNumber('titleOffsetY')!;
  130. if (e['titleOffsetX'] != null) yAxis_data.titleOffsetX = e.getNumber('titleOffsetX')!;
  131. if (e['titleFontColor'] != null) yAxis_data.titleFontColor = e.getString('titleFontColor')!;
  132. if (e['min'] != null) yAxis_data.min = e.getNumber('min')!;
  133. if (e['max'] != null) yAxis_data.max = e.getNumber('max')!;
  134. if (e['tofix'] != null) yAxis_data.tofix = e.getNumber('tofix')!;
  135. if (e['unit'] != null) yAxis_data.unit = e.getString('unit')!;
  136. if (e['formatter'] != null) yAxis_data.formatter = e.getAny('formatter')!;
  137. if (e['format'] != null) yAxis_data.format = e.getString('format')!;
  138. return yAxis_data;
  139. }
  140. export function yAxisInit(e : UTSJSONObject) : ChartOptionsYAxis {
  141. const yAxis : ChartOptionsYAxis = new ChartOptionsYAxis();
  142. if (e['disabled'] != null) yAxis.disabled = e.getBoolean('disabled')!;
  143. if (e['disableGrid'] != null) yAxis.disableGrid = e.getBoolean('disableGrid')!;
  144. if (e['splitNumber'] != null) yAxis.splitNumber = e.getNumber('splitNumber')!;
  145. if (e['gridType'] != null) yAxis.gridType = e.getString('gridType') as 'solid' | 'dash';
  146. if (e['dashLength'] != null) yAxis.dashLength = e.getNumber('dashLength')!;
  147. if (e['gridColor'] != null) yAxis.gridColor = e.getString('gridColor')!;
  148. if (e['padding'] != null) yAxis.padding = e.getNumber('padding')!;
  149. if (e['showTitle'] != null) yAxis.showTitle = e.getBoolean('showTitle')!;
  150. if (e['gridSet'] != null) yAxis.gridSet = e.getString('gridSet')!;
  151. if (e['fontColor'] != null) yAxis.fontColor = e.getString('fontColor')!;
  152. if (e['data'] != null) {
  153. const yAxis_data : ChartOptionsYAxisData[] = []
  154. const data = e.getArray('data') as UTSJSONObject[]
  155. data.forEach((item : UTSJSONObject) => {
  156. yAxis_data.push(yAxisDataInit(item))
  157. })
  158. yAxis.data = yAxis_data
  159. }
  160. return yAxis;
  161. }
  162. export function legendInit(e : UTSJSONObject) : ChartOptionsLegend {
  163. const legend = new ChartOptionsLegend();
  164. if (e['show'] != null) legend.show = e.getBoolean('show')!;
  165. if (e['position'] != null) legend.position = e.getString('position') as 'bottom' | 'top' | 'left' | 'right';
  166. if (e['float'] != null) legend.float = e.getString('float') as 'center' | 'left' | 'right' | 'top' | 'bottom';
  167. if (e['padding'] != null) legend.padding = e.getNumber('padding')!;
  168. if (e['margin'] != null) legend.margin = e.getNumber('margin')!;
  169. if (e['backgroundColor'] != null) legend.backgroundColor = e.getString('backgroundColor')!;
  170. if (e['borderColor'] != null) legend.borderColor = e.getString('borderColor')!;
  171. if (e['borderWidth'] != null) legend.borderWidth = e.getNumber('borderWidth')!;
  172. if (e['fontSize'] != null) legend.fontSize = e.getNumber('fontSize')!;
  173. if (e['fontColor'] != null) legend.fontColor = e.getString('fontColor')!;
  174. if (e['lineHeight'] != null) legend.lineHeight = e.getNumber('lineHeight')!;
  175. if (e['hiddenColor'] != null) legend.hiddenColor = e.getString('hiddenColor')!;
  176. if (e['itemGap'] != null) legend.itemGap = e.getNumber('itemGap')!;
  177. return legend;
  178. }
  179. export function titleInit(e : UTSJSONObject) : ChartOptionsTitle {
  180. const title = new ChartOptionsTitle();
  181. if (e['name'] != null) title.name = e.getString('name')!;
  182. if (e['fontSize'] != null) title.fontSize = e.getNumber('fontSize')!;
  183. if (e['color'] != null) title.color = e.getString('color')!;
  184. if (e['offsetX'] != null) title.offsetX = e.getNumber('offsetX')!;
  185. if (e['offsetY'] != null) title.offsetY = e.getNumber('offsetY')!;
  186. return title;
  187. }
  188. export function subtitleInit(e : UTSJSONObject) : ChartOptionsSubTitle {
  189. const subtitle = new ChartOptionsSubTitle();
  190. if (e['name'] != null) subtitle.name = e.getString('name')!;
  191. if (e['fontSize'] != null) subtitle.fontSize = e.getNumber('fontSize')!;
  192. if (e['color'] != null) subtitle.color = e.getString('color')!;
  193. if (e['offsetX'] != null) subtitle.offsetX = e.getNumber('offsetX')!;
  194. if (e['offsetY'] != null) subtitle.offsetY = e.getNumber('offsetY')!;
  195. return subtitle;
  196. }
  197. export function mapSeriesPropertiesParentInit(e : UTSJSONObject) : ChartOptionsMapSeriesPropertiesParent {
  198. const parent = new ChartOptionsMapSeriesPropertiesParent()
  199. if (e['adcode'] != null) parent.adcode = e.getNumber('adcode')!
  200. return parent
  201. }
  202. export function mapSeriesPropertiesInit(e : UTSJSONObject) : ChartOptionsMapSeriesProperties {
  203. const mapSeriesProperties = new ChartOptionsMapSeriesProperties()
  204. if (e['adcode'] != null) mapSeriesProperties.adcode = e.getNumber('adcode')!
  205. if (e['name'] != null) mapSeriesProperties.name = e.getString('name')!
  206. if (e['center'] != null) mapSeriesProperties.center = e.getArray('center') as number[]
  207. if (e['centroid'] != null) mapSeriesProperties.centroid = e.getArray('centroid') as number[]
  208. if (e['childrenNum'] != null) mapSeriesProperties.childrenNum = e.getNumber('childrenNum')!
  209. if (e['level'] != null) mapSeriesProperties.level = e.getString('level')!
  210. if (e['subFeatureIndex'] != null) mapSeriesProperties.subFeatureIndex = e.getNumber('subFeatureIndex')!
  211. if (e['acroutes'] != null) mapSeriesProperties.acroutes = e.getArray('acroutes') as number[]
  212. if (e['parent'] != null) {
  213. mapSeriesProperties.parent = mapSeriesPropertiesParentInit(e.getJSON('parent')!)
  214. }
  215. return mapSeriesProperties
  216. }
  217. export function mapSeriesGeometryInit(e : UTSJSONObject) : ChartOptionsMapSeriesGeometry {
  218. const geometry = new ChartOptionsMapSeriesGeometry()
  219. if (e['type'] != null) geometry.type = e.getString('type')!;
  220. if (e['coordinates'] != null) geometry.coordinates = e.getArray('coordinates') as number[][][][];
  221. return geometry
  222. }
  223. export function optionsInit(e : UTSJSONObject) : ChartOptions {
  224. const opts = new ChartOptions()
  225. opts.canvasContext = e['canvasContext'] as CanvasContext
  226. opts.context = e['context'] as CanvasRenderingContext2D
  227. if (e['type'] != null) opts.type = e.getString('type')!
  228. if (opts.type == 'gauge') {
  229. if (e['categories'] != null) {
  230. const categoriesObj : ChartOptionsSeriesData[] = []
  231. const cate : UTSJSONObject[] = e.getArray('categories') as UTSJSONObject[]
  232. cate.forEach((item : UTSJSONObject) => {
  233. const child = seriesDataInit(item)
  234. categoriesObj.push(child)
  235. })
  236. opts.categoriesObj = categoriesObj
  237. }
  238. } else {
  239. if (e['categories'] != null) opts.categories = e.getArray('categories') as string[]
  240. }
  241. if (e['width'] != null) opts.width = e.getNumber('width')!
  242. if (e['height'] != null) opts.height = e.getNumber('height')!
  243. if (e['canvas2d'] != null) opts.canvas2d = e.getBoolean('canvas2d')!
  244. if (e['pixelRatio'] != null) opts.pixelRatio = e.getNumber('pixelRatio')!
  245. if (e['animation'] != null) opts.animation = e.getBoolean('animation')!
  246. if (e['timing'] != null) opts.timing = e.getString('timing')!
  247. if (e['duration'] != null) opts.duration = e.getNumber('duration')!
  248. if (e['rotate'] != null) opts.rotate = e.getBoolean('rotate')!
  249. if (e['rotateLock'] != null) opts.rotateLock = e.getBoolean('rotateLock')!
  250. if (e['background'] != null) opts.background = e.getString('background')!
  251. if (e['color'] != null) opts.color = e.getArray('color') as string[]
  252. if (e['padding'] != null) opts.padding = e.getArray('padding') as number[]
  253. if (e['fontSize'] != null) opts.fontSize = e.getNumber('fontSize')!
  254. if (e['fontColor'] != null) opts.fontColor = e.getString('fontColor')!
  255. if (e['dataLabel'] != null) opts.dataLabel = e.getBoolean('dataLabel')!
  256. if (e['dataPointShape'] != null) opts.dataPointShape = e.getBoolean('dataPointShape')!
  257. if (e['dataPointShapeType'] != null) opts.dataPointShapeType = e.getString('dataPointShapeType')!
  258. if (e['touchMoveLimit'] != null) opts.touchMoveLimit = e.getNumber('touchMoveLimit')!
  259. if (e['enableScroll'] != null) opts.enableScroll = e.getBoolean('enableScroll')!
  260. if (e['enableMarkLine'] != null) opts.enableMarkLine = e.getBoolean('enableMarkLine')!
  261. if (e['scrollPosition'] != null) opts.scrollPosition = e.getString('scrollPosition')!
  262. if (e['xOffset'] != null) opts.xOffset = e.getNumber('xOffset')!
  263. if (e['yOffset'] != null) opts.yOffset = e.getNumber('yOffset')!
  264. if (e['tapLegend'] != null) opts.dataLabel = e.getBoolean('tapLegend')!
  265. opts.legend.fontSize = opts.fontSize
  266. opts.legend.lineHeight = opts.fontSize
  267. opts.legend.fontColor = opts.fontColor
  268. opts.yAxis.dashLength = 4 * opts.pixelRatio
  269. if (e['series'] != null) {
  270. const series : ChartOptionsSeries[] = []
  271. const series_data = e.getArray('series') as UTSJSONObject[]
  272. series_data.forEach((item : UTSJSONObject) => {
  273. series.push(seriesInit(item, opts.type))
  274. })
  275. opts.series = series
  276. }
  277. if (e['xAxis'] != null) {
  278. opts.xAxis = xAxisInit(e.getJSON('xAxis')!)
  279. }
  280. if (e['yAxis'] != null) {
  281. opts.yAxis = yAxisInit(e.getJSON('yAxis')!)
  282. }
  283. if (e['legend'] != null) {
  284. opts.legend = legendInit(e.getJSON('legend')!)
  285. }
  286. if (e['title'] != null) {
  287. opts.title = titleInit(e.getJSON('title')!)
  288. }
  289. if (e['subtitle'] != null) {
  290. opts.subtitle = subtitleInit(e.getJSON('subtitle')!)
  291. }
  292. if (e['extra'] != null) {
  293. opts.extra = extraInit(e.getJSON('extra')!)
  294. }
  295. return opts
  296. }
  297. export function updateOptions(_opts : ChartOptions, e : UTSJSONObject) {
  298. const opts = _opts
  299. if (e['type'] != null) opts.type = e.getString('type')!
  300. if (opts.type == 'gauge') {
  301. if (e['categories'] != null) {
  302. const categoriesObj : ChartOptionsSeriesData[] = []
  303. const cate : UTSJSONObject[] = e.getArray('categories') as UTSJSONObject[]
  304. cate.forEach((item : UTSJSONObject) => {
  305. const child = seriesDataInit(item)
  306. categoriesObj.push(child)
  307. })
  308. opts.categoriesObj = categoriesObj
  309. }
  310. } else {
  311. if (e['categories'] != null) opts.categories = e.getArray('categories') as string[]
  312. }
  313. if (e['width'] != null) opts.width = e.getNumber('width')!
  314. if (e['height'] != null) opts.height = e.getNumber('height')!
  315. if (e['canvas2d'] != null) opts.canvas2d = e.getBoolean('canvas2d')!
  316. if (e['pixelRatio'] != null) opts.pixelRatio = e.getNumber('pixelRatio')!
  317. if (e['animation'] != null) opts.animation = e.getBoolean('animation')!
  318. if (e['timing'] != null) opts.timing = e.getString('timing')!
  319. if (e['duration'] != null) opts.duration = e.getNumber('duration')!
  320. if (e['rotate'] != null) opts.rotate = e.getBoolean('rotate')!
  321. if (e['rotateLock'] != null) opts.rotateLock = e.getBoolean('rotateLock')!
  322. if (e['background'] != null) opts.background = e.getString('background')!
  323. if (e['color'] != null) opts.color = e.getArray('color') as string[]
  324. if (e['padding'] != null) opts.padding = e.getArray('padding') as number[]
  325. if (e['fontSize'] != null) opts.fontSize = e.getNumber('fontSize')!
  326. if (e['fontColor'] != null) opts.fontColor = e.getString('fontColor')!
  327. if (e['dataLabel'] != null) opts.dataLabel = e.getBoolean('dataLabel')!
  328. if (e['dataPointShape'] != null) opts.dataPointShape = e.getBoolean('dataPointShape')!
  329. if (e['dataPointShapeType'] != null) opts.dataPointShapeType = e.getString('dataPointShapeType')!
  330. if (e['touchMoveLimit'] != null) opts.touchMoveLimit = e.getNumber('touchMoveLimit')!
  331. if (e['enableScroll'] != null) opts.enableScroll = e.getBoolean('enableScroll')!
  332. if (e['enableMarkLine'] != null) opts.enableMarkLine = e.getBoolean('enableMarkLine')!
  333. if (e['scrollPosition'] != null) opts.scrollPosition = e.getString('scrollPosition')!
  334. if (e['xOffset'] != null) opts.xOffset = e.getNumber('xOffset')!
  335. if (e['yOffset'] != null) opts.yOffset = e.getNumber('yOffset')!
  336. if (e['tapLegend'] != null) opts.dataLabel = e.getBoolean('tapLegend')!
  337. opts.legend.fontSize = opts.fontSize
  338. opts.legend.lineHeight = opts.fontSize
  339. opts.legend.fontColor = opts.fontColor
  340. opts.yAxis.dashLength = 4 * opts.pixelRatio
  341. if (e['series'] != null) {
  342. const series : ChartOptionsSeries[] = []
  343. const series_data = e.getArray('series') as UTSJSONObject[]
  344. series_data.forEach((item : UTSJSONObject) => {
  345. series.push(seriesInit(item, opts.type))
  346. })
  347. opts.series = series
  348. }
  349. if (e['xAxis'] != null) {
  350. opts.xAxis = xAxisInit(e.getJSON('xAxis')!)
  351. }
  352. if (e['yAxis'] != null) {
  353. opts.yAxis = yAxisInit(e.getJSON('yAxis')!)
  354. }
  355. if (e['legend'] != null) {
  356. opts.legend = legendInit(e.getJSON('legend')!)
  357. }
  358. if (e['title'] != null) {
  359. opts.title = titleInit(e.getJSON('title')!)
  360. }
  361. if (e['subtitle'] != null) {
  362. opts.subtitle = subtitleInit(e.getJSON('subtitle')!)
  363. }
  364. if (e['extra'] != null) {
  365. opts.extra = extraInit(e.getJSON('extra')!)
  366. }
  367. return opts
  368. }