@operato/chart 9.0.0-beta.7 → 9.0.0-beta.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +341 -0
  2. package/dist/src/chartjs/config-converter.d.ts +1 -0
  3. package/dist/src/chartjs/config-converter.js.map +1 -1
  4. package/dist/src/chartjs/ox-chart-js.d.ts +3 -2
  5. package/dist/src/chartjs/ox-chart-js.js.map +1 -1
  6. package/dist/src/editors/configurer.d.ts +3 -2
  7. package/dist/src/editors/configurer.js.map +1 -1
  8. package/dist/src/editors/input-chart-abstract.d.ts +2 -1
  9. package/dist/src/editors/input-chart-abstract.js +1 -1
  10. package/dist/src/editors/input-chart-abstract.js.map +1 -1
  11. package/dist/src/editors/input-chart-styles.js +12 -11
  12. package/dist/src/editors/input-chart-styles.js.map +1 -1
  13. package/dist/src/editors/ox-input-chart-hbar.d.ts +1 -0
  14. package/dist/src/editors/ox-input-chart-hbar.js.map +1 -1
  15. package/dist/src/editors/ox-input-chart-pie.d.ts +1 -0
  16. package/dist/src/editors/ox-input-chart-pie.js.map +1 -1
  17. package/dist/src/editors/ox-input-chart-radar.d.ts +1 -0
  18. package/dist/src/editors/ox-input-chart-radar.js.map +1 -1
  19. package/dist/src/editors/ox-input-chart-timeseries.js +1 -1
  20. package/dist/src/editors/ox-input-chart-timeseries.js.map +1 -1
  21. package/dist/src/editors/ox-property-editor-chart.js +3 -3
  22. package/dist/src/editors/ox-property-editor-chart.js.map +1 -1
  23. package/dist/src/editors/templates/annotations.d.ts +1 -0
  24. package/dist/src/editors/templates/annotations.js +10 -0
  25. package/dist/src/editors/templates/annotations.js.map +1 -1
  26. package/dist/src/editors/templates/series.d.ts +1 -0
  27. package/dist/src/editors/templates/series.js.map +1 -1
  28. package/dist/src/index.d.ts +1 -0
  29. package/dist/src/index.js +2 -1
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/scichart/ox-scichart.d.ts +3 -2
  32. package/dist/src/scichart/ox-scichart.js +7 -3
  33. package/dist/src/scichart/ox-scichart.js.map +1 -1
  34. package/dist/src/scichart/scichart-builder.d.ts +2 -1
  35. package/dist/src/scichart/scichart-builder.js +225 -63
  36. package/dist/src/scichart/scichart-builder.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +13 -7
  39. package/types/types.d.ts +2 -1
  40. package/dist/stories/common.d.ts +0 -7
  41. package/dist/stories/common.js +0 -78
  42. package/dist/stories/common.js.map +0 -1
  43. package/dist/stories/ox-input-chart-bar.stories.d.ts +0 -25
  44. package/dist/stories/ox-input-chart-bar.stories.js +0 -173
  45. package/dist/stories/ox-input-chart-bar.stories.js.map +0 -1
  46. package/dist/stories/ox-input-chart-doughnut.stories.d.ts +0 -27
  47. package/dist/stories/ox-input-chart-doughnut.stories.js +0 -115
  48. package/dist/stories/ox-input-chart-doughnut.stories.js.map +0 -1
  49. package/dist/stories/ox-input-chart-hbar.stories.d.ts +0 -25
  50. package/dist/stories/ox-input-chart-hbar.stories.js +0 -174
  51. package/dist/stories/ox-input-chart-hbar.stories.js.map +0 -1
  52. package/dist/stories/ox-input-chart-line.stories.d.ts +0 -25
  53. package/dist/stories/ox-input-chart-line.stories.js +0 -184
  54. package/dist/stories/ox-input-chart-line.stories.js.map +0 -1
  55. package/dist/stories/ox-input-chart-pie.stories.d.ts +0 -27
  56. package/dist/stories/ox-input-chart-pie.stories.js +0 -115
  57. package/dist/stories/ox-input-chart-pie.stories.js.map +0 -1
  58. package/dist/stories/ox-input-chart-polar-area.stories.d.ts +0 -27
  59. package/dist/stories/ox-input-chart-polar-area.stories.js +0 -115
  60. package/dist/stories/ox-input-chart-polar-area.stories.js.map +0 -1
  61. package/dist/stories/ox-input-chart-radar.stories.d.ts +0 -27
  62. package/dist/stories/ox-input-chart-radar.stories.js +0 -126
  63. package/dist/stories/ox-input-chart-radar.stories.js.map +0 -1
  64. package/dist/stories/ox-input-chart-timeseries.stories.d.ts +0 -25
  65. package/dist/stories/ox-input-chart-timeseries.stories.js +0 -253
  66. package/dist/stories/ox-input-chart-timeseries.stories.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"series.js","sourceRoot":"","sources":["../../../../src/editors/templates/series.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGlE,OAAO,oBAAoB,CAAA;AAGpB,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU;IACpD,gBAAgB;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IASS,OAAO,CAAC,kBAAkC;QAClD,IAAI,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAChF,IAAI,CAAC,aAAa,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAA;IACjC,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CACV,IAAI,CAAC,UAAU,CAAC,kBAAkB,EAClC,IAAI,CAAA;;+CAEqC,IAAI,CAAC,cAAc;8DACJ,IAAI,CAAC,WAAW;qDACzB,IAAI,CAAC,UAAU,CAAC,kBAAkB;gBACvE,IAAI,CAAC,WAAW,EAAE;;+DAE6B,IAAI,CAAC,YAAY;;;qDAG3B,IAAI,CAAC,UAAU;;YAExD,IAAI,CAAC,iBAAiB,EAAE;;OAE7B,CACF,CAAA;IACH,CAAC;IAEO,WAAW;QACjB,O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C;AAC9B;IAAtC,KAAK,CAAC,8BAA8B,CAAC;uEAAiC;AAV5D,sBAAsB;IADlC,aAAa,CAAC,iBAAiB,CAAC;GACpB,sBAAsB,CA+SlC","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { LitElement, html, PropertyValues, nothing } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { keyed } from 'lit/directives/keyed.js'\nimport { MdIcon } from '@material/web/icon/icon.js'\nimport { random as randomColor, TinyColor } from '@ctrl/tinycolor'\n\nimport { Configurer } from '../configurer.js'\nimport './display-value.js'\n\n@customElement('ox-chart-series')\nexport class MultipleSeriesTemplate extends LitElement {\n createRenderRoot() {\n return this\n }\n\n @property({ type: Object }) configurer!: Configurer\n @property({ type: String }) chartType?: OperatoChart.ChartType\n\n @query('#series-tabs') seriesTabs!: HTMLElement\n @query('#series-tab-nav-left-button') seriesTabNavLeftButton!: MdIcon\n @query('#series-tab-nav-right-button') seriesTabNavRightButton!: MdIcon\n\n protected updated(_changedProperties: PropertyValues): void {\n if (_changedProperties.has('configurer') || _changedProperties.has('chartType')) {\n this.requestUpdate()\n }\n }\n\n get value() {\n return this.configurer.datasets\n }\n\n render() {\n return keyed(\n this.configurer.currentSeriesIndex,\n html`\n <div id=\"series-properties-container\" fullwidth>\n <div id=\"series-tab-header\" @wheel=${this._onWheelScroll}>\n <md-icon id=\"series-tab-nav-left-button\" @click=${this._scrollLeft}>chevron_left</md-icon>\n <div id=\"series-tabs\" active-tab-index=${this.configurer.currentSeriesIndex} fit-container>\n ${this._renderTabs()}\n </div>\n <md-icon id=\"series-tab-nav-right-button\" @click=${this._scrollRight}>chevron_right</md-icon>\n </div>\n <div id=\"add-series-button-container\">\n <md-icon id=\"add-series-button\" @click=${this._addSeries}>add</md-icon>\n </div>\n ${this._renderSeriesForm()}\n </div>\n `\n )\n }\n\n private _renderTabs() {\n return this.configurer.datasets.map(\n (dataset: OperatoChart.Dataset, index: number) => html`\n <div\n data-series=${index + 1}\n data-tab-index=${index}\n tab\n ?selected=${index === this.configurer.currentSeriesIndex}\n @click=${() => this._selectTab(index)}\n >\n ${index + 1}\n ${this.configurer.datasets.length > 1 && this.configurer.currentSeriesIndex === index\n ? html`<md-icon @click=${() => this._removeSeries(index)}>close</md-icon>`\n : html``}\n </div>\n `\n )\n }\n\n private _renderSeriesForm() {\n const configurer = this.configurer\n const chartType = this.chartType\n\n return html`\n <div class=\"tab-content\">\n <label for=\"data-key\"> <ox-i18n msgid=\"label.data-key\">Data Key</ox-i18n> </label>\n <input id=\"data-key\" type=\"text\" value-key=\"dataKey\" .value=${configurer.dataKey || ''} />\n\n ${chartType == 'horizontalBar' ||\n chartType === 'doughnut' ||\n chartType === 'pie' ||\n chartType == 'radar' ||\n chartType == 'polarArea'\n ? nothing\n : html`\n <label for=\"series-type\"> <ox-i18n msgid=\"label.series-type\">Type</ox-i18n> </label>\n <select\n id=\"series-type\"\n class=\"select-content\"\n value-key=\"series.type\"\n .value=${configurer.series.type || ''}\n >\n <option value=\"bar\" selected>Bar</option>\n <option value=\"line\">Line</option>\n </select>\n `}\n\n <label for=\"series-label\"> <ox-i18n msgid=\"label.label\">Label</ox-i18n> </label>\n <input id=\"series-label\" type=\"text\" value-key=\"series.label\" .value=${configurer.series.label || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-line-tension\"> <ox-i18n msgid=\"label.line-tension\">Line Tension</ox-i18n> </label>\n <select\n id=\"series-line-tension\"\n class=\"select-content\"\n value-key=\"series.lineTension\"\n .value=${String(configurer.series.lineTension || 0)}\n >\n <option value=\"0.4\">Smooth</option>\n <option value=\"0\">Angled</option>\n </select>\n `\n : html``}\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-border-width\"> <ox-i18n msgid=\"label.border-width\">Border Width</ox-i18n> </label>\n <input\n id=\"series-border-width\"\n type=\"number\"\n value-key=\"series.borderWidth\"\n .value=${String(configurer.series.borderWidth || 0)}\n />\n `\n : html``}\n\n <label for=\"series-color\"> <ox-i18n msgid=\"label.color\">Color</ox-i18n> </label>\n <ox-input-color id=\"series-color\" value-key=\"color\" .value=${configurer.color}></ox-input-color>\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-point-style\"> <ox-i18n msgid=\"label.point-shape\">Point Shape</ox-i18n> </label>\n <select\n id=\"series-point-style\"\n class=\"select-content\"\n value-key=\"series.pointStyle\"\n .value=${configurer.series.pointStyle || ''}\n >\n <option value=\"\">&nbsp;</option>\n <option value=\"circle\">⚬</option>\n <option value=\"triangle\">▵</option>\n <option value=\"rect\">□</option>\n <option value=\"rectRot\">◇</option>\n <option value=\"cross\">+</option>\n <option value=\"crossRot\">⨉</option>\n <option value=\"star\">✱</option>\n <option value=\"line\">―</option>\n <option value=\"dash\">┄</option>\n </select>\n\n <label for=\"series-point-radius\"> <ox-i18n msgid=\"label.point-size\">Point Size</ox-i18n> </label>\n <input\n id=\"series-point-radius\"\n type=\"number\"\n value-key=\"series.pointRadius\"\n .value=${String(configurer.series.pointRadius || 0)}\n />\n `\n : html``}\n\n <label for=\"series-stack\"> <ox-i18n msgid=\"label.stack-group\">Stack group</ox-i18n> </label>\n <input id=\"series-stack\" type=\"text\" value-key=\"series.stack\" .value=${configurer.series.stack || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <input id=\"series-fill\" type=\"checkbox\" value-key=\"series.fill\" ?checked=${configurer.series.fill} />\n <label for=\"series-fill\"> <ox-i18n msgid=\"label.fill\">Fill</ox-i18n> </label>\n `\n : html``}\n ${configurer.multiAxis && configurer.series.type !== 'horizontalBar'\n ? html`\n <label for=\"series-y-axis-id\"> <ox-i18n msgid=\"label.target-axis\">Target Axis</ox-i18n> </label>\n <select\n id=\"series-y-axis-id\"\n class=\"select-content\"\n value-key=\"series.yAxisID\"\n .value=${configurer.series.yAxisID || ''}\n >\n <option value=\"left\">Left</option>\n <option value=\"right\">Right</option>\n </select>\n `\n : html``}\n\n <label></label>\n <ox-chart-display-value .configurer=${configurer} fullwidth></ox-chart-display-value>\n </div>\n `\n }\n\n _getSeriesModel({\n chartType,\n datasetsLength,\n lastSeriesColor\n }: {\n chartType: string\n datasetsLength: number\n lastSeriesColor: TinyColor\n }) {\n const addSeriesOption: any = {\n label: `series ${datasetsLength + 1}`,\n data: [],\n borderWidth: 1,\n dataKey: '',\n yAxisID: 'left',\n color: randomColor({\n hue: lastSeriesColor.toHsv().h\n }).toRgbString(),\n stack: ''\n }\n\n addSeriesOption.type = addSeriesOption.chartType = chartType\n return addSeriesOption\n }\n\n private _selectTab(index: number) {\n this.configurer.setCurrentSeriesIndex(index)\n this.requestUpdate()\n }\n\n private _removeSeries(index: number) {\n this.configurer.removeSeries(index)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.requestUpdate()\n }\n\n private _addSeries() {\n const configurer = this.configurer\n\n if (!configurer.config.data.datasets) {\n return\n }\n\n const lastSeriesIndex = configurer.config.data.datasets.length\n const chartType = configurer.series.type || configurer.config.type\n const color = configurer.datasets[lastSeriesIndex - 1]?.backgroundColor\n const lastSeriesColor = new TinyColor(Array.isArray(color) ? color[0] : color)\n\n const seriesModel = this._getSeriesModel({\n chartType: chartType!,\n datasetsLength: lastSeriesIndex,\n lastSeriesColor\n })\n\n this.configurer.addSeries(seriesModel)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.requestUpdate()\n }\n\n private _onWheelScroll(event: WheelEvent) {\n const tabContainer = this.seriesTabs\n if (tabContainer) {\n event.preventDefault()\n\n tabContainer.scrollLeft += event.deltaY\n\n this._onTabScroll()\n }\n }\n\n private _scrollLeft() {\n this._scrollTabContainer(-1)\n }\n\n private _scrollRight() {\n this._scrollTabContainer(1)\n }\n\n private _scrollTabContainer(direction: number) {\n const tabContainer = this.renderRoot!.querySelector<HTMLElement>('#series-tabs')\n if (tabContainer) {\n tabContainer.style.scrollBehavior = 'smooth'\n tabContainer.scrollLeft += direction * tabContainer.clientWidth\n }\n\n setTimeout(() => {\n tabContainer!.style.scrollBehavior = 'auto'\n this._onTabScroll()\n }, 300)\n }\n\n private _onTabScroll() {\n let tabContainer: HTMLElement | null | undefined\n let tabNavLeftButton: MdIcon\n let tabNavRightButton: MdIcon\n\n tabContainer = this.seriesTabs\n tabNavLeftButton = this.seriesTabNavLeftButton\n tabNavRightButton = this.seriesTabNavRightButton\n\n if (!tabContainer) {\n return\n }\n\n if (tabContainer.clientWidth == tabContainer.scrollWidth) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.setAttribute('disabled', '')\n } else if (tabContainer.scrollLeft <= 0) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.removeAttribute('disabled')\n } else if (tabContainer.scrollLeft + tabContainer.clientWidth >= tabContainer.scrollWidth) {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.setAttribute('disabled', '')\n } else {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.removeAttribute('disabled')\n }\n }\n}\n"]}
1
+ {"version":3,"file":"series.js","sourceRoot":"","sources":["../../../../src/editors/templates/series.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAKlE,OAAO,oBAAoB,CAAA;AAGpB,IAAM,sBAAsB,GAA5B,MAAM,sBAAuB,SAAQ,UAAU;IACpD,gBAAgB;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IASS,OAAO,CAAC,kBAAkC;QAClD,IAAI,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,C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eAAe,CAAC,UAAU,CAAC,CAAA;YAC5C,iBAAiB,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;YAC5C,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;CACF,CAAA;AA1S6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAmC;AAEvC;IAAtB,KAAK,CAAC,cAAc,CAAC;0DAAyB;AACT;IAArC,KAAK,CAAC,6BAA6B,CAAC;sEAAgC;AAC9B;IAAtC,KAAK,CAAC,8BAA8B,CAAC;uEAAiC;AAV5D,sBAAsB;IADlC,aAAa,CAAC,iBAAiB,CAAC;GACpB,sBAAsB,CA+SlC","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { LitElement, html, PropertyValues, nothing } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { keyed } from 'lit/directives/keyed.js'\nimport { MdIcon } from '@material/web/icon/icon.js'\nimport { random as randomColor, TinyColor } from '@ctrl/tinycolor'\n\nimport { Configurer } from '../configurer.js'\nimport type { OperatoChart } from '../../../types/types.d.ts'\n\nimport './display-value.js'\n\n@customElement('ox-chart-series')\nexport class MultipleSeriesTemplate extends LitElement {\n createRenderRoot() {\n return this\n }\n\n @property({ type: Object }) configurer!: Configurer\n @property({ type: String }) chartType?: OperatoChart.ChartType\n\n @query('#series-tabs') seriesTabs!: HTMLElement\n @query('#series-tab-nav-left-button') seriesTabNavLeftButton!: MdIcon\n @query('#series-tab-nav-right-button') seriesTabNavRightButton!: MdIcon\n\n protected updated(_changedProperties: PropertyValues): void {\n if (_changedProperties.has('configurer') || _changedProperties.has('chartType')) {\n this.requestUpdate()\n }\n }\n\n get value() {\n return this.configurer.datasets\n }\n\n render() {\n return keyed(\n this.configurer.currentSeriesIndex,\n html`\n <div id=\"series-properties-container\" fullwidth>\n <div id=\"series-tab-header\" @wheel=${this._onWheelScroll}>\n <md-icon id=\"series-tab-nav-left-button\" @click=${this._scrollLeft}>chevron_left</md-icon>\n <div id=\"series-tabs\" active-tab-index=${this.configurer.currentSeriesIndex} fit-container>\n ${this._renderTabs()}\n </div>\n <md-icon id=\"series-tab-nav-right-button\" @click=${this._scrollRight}>chevron_right</md-icon>\n </div>\n <div id=\"add-series-button-container\">\n <md-icon id=\"add-series-button\" @click=${this._addSeries}>add</md-icon>\n </div>\n ${this._renderSeriesForm()}\n </div>\n `\n )\n }\n\n private _renderTabs() {\n return this.configurer.datasets.map(\n (dataset: OperatoChart.Dataset, index: number) => html`\n <div\n data-series=${index + 1}\n data-tab-index=${index}\n tab\n ?selected=${index === this.configurer.currentSeriesIndex}\n @click=${() => this._selectTab(index)}\n >\n ${index + 1}\n ${this.configurer.datasets.length > 1 && this.configurer.currentSeriesIndex === index\n ? html`<md-icon @click=${() => this._removeSeries(index)}>close</md-icon>`\n : html``}\n </div>\n `\n )\n }\n\n private _renderSeriesForm() {\n const configurer = this.configurer\n const chartType = this.chartType\n\n return html`\n <div class=\"tab-content\">\n <label for=\"data-key\"> <ox-i18n msgid=\"label.data-key\">Data Key</ox-i18n> </label>\n <input id=\"data-key\" type=\"text\" value-key=\"dataKey\" .value=${configurer.dataKey || ''} />\n\n ${chartType == 'horizontalBar' ||\n chartType === 'doughnut' ||\n chartType === 'pie' ||\n chartType == 'radar' ||\n chartType == 'polarArea'\n ? nothing\n : html`\n <label for=\"series-type\"> <ox-i18n msgid=\"label.series-type\">Type</ox-i18n> </label>\n <select\n id=\"series-type\"\n class=\"select-content\"\n value-key=\"series.type\"\n .value=${configurer.series.type || ''}\n >\n <option value=\"bar\" selected>Bar</option>\n <option value=\"line\">Line</option>\n </select>\n `}\n\n <label for=\"series-label\"> <ox-i18n msgid=\"label.label\">Label</ox-i18n> </label>\n <input id=\"series-label\" type=\"text\" value-key=\"series.label\" .value=${configurer.series.label || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-line-tension\"> <ox-i18n msgid=\"label.line-tension\">Line Tension</ox-i18n> </label>\n <select\n id=\"series-line-tension\"\n class=\"select-content\"\n value-key=\"series.lineTension\"\n .value=${String(configurer.series.lineTension || 0)}\n >\n <option value=\"0.4\">Smooth</option>\n <option value=\"0\">Angled</option>\n </select>\n `\n : html``}\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-border-width\"> <ox-i18n msgid=\"label.border-width\">Border Width</ox-i18n> </label>\n <input\n id=\"series-border-width\"\n type=\"number\"\n value-key=\"series.borderWidth\"\n .value=${String(configurer.series.borderWidth || 0)}\n />\n `\n : html``}\n\n <label for=\"series-color\"> <ox-i18n msgid=\"label.color\">Color</ox-i18n> </label>\n <ox-input-color id=\"series-color\" value-key=\"color\" .value=${configurer.color}></ox-input-color>\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-point-style\"> <ox-i18n msgid=\"label.point-shape\">Point Shape</ox-i18n> </label>\n <select\n id=\"series-point-style\"\n class=\"select-content\"\n value-key=\"series.pointStyle\"\n .value=${configurer.series.pointStyle || ''}\n >\n <option value=\"\">&nbsp;</option>\n <option value=\"circle\">⚬</option>\n <option value=\"triangle\">▵</option>\n <option value=\"rect\">□</option>\n <option value=\"rectRot\">◇</option>\n <option value=\"cross\">+</option>\n <option value=\"crossRot\">⨉</option>\n <option value=\"star\">✱</option>\n <option value=\"line\">―</option>\n <option value=\"dash\">┄</option>\n </select>\n\n <label for=\"series-point-radius\"> <ox-i18n msgid=\"label.point-size\">Point Size</ox-i18n> </label>\n <input\n id=\"series-point-radius\"\n type=\"number\"\n value-key=\"series.pointRadius\"\n .value=${String(configurer.series.pointRadius || 0)}\n />\n `\n : html``}\n\n <label for=\"series-stack\"> <ox-i18n msgid=\"label.stack-group\">Stack group</ox-i18n> </label>\n <input id=\"series-stack\" type=\"text\" value-key=\"series.stack\" .value=${configurer.series.stack || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <input id=\"series-fill\" type=\"checkbox\" value-key=\"series.fill\" ?checked=${configurer.series.fill} />\n <label for=\"series-fill\"> <ox-i18n msgid=\"label.fill\">Fill</ox-i18n> </label>\n `\n : html``}\n ${configurer.multiAxis && configurer.series.type !== 'horizontalBar'\n ? html`\n <label for=\"series-y-axis-id\"> <ox-i18n msgid=\"label.target-axis\">Target Axis</ox-i18n> </label>\n <select\n id=\"series-y-axis-id\"\n class=\"select-content\"\n value-key=\"series.yAxisID\"\n .value=${configurer.series.yAxisID || ''}\n >\n <option value=\"left\">Left</option>\n <option value=\"right\">Right</option>\n </select>\n `\n : html``}\n\n <label></label>\n <ox-chart-display-value .configurer=${configurer} fullwidth></ox-chart-display-value>\n </div>\n `\n }\n\n _getSeriesModel({\n chartType,\n datasetsLength,\n lastSeriesColor\n }: {\n chartType: string\n datasetsLength: number\n lastSeriesColor: TinyColor\n }) {\n const addSeriesOption: any = {\n label: `series ${datasetsLength + 1}`,\n data: [],\n borderWidth: 1,\n dataKey: '',\n yAxisID: 'left',\n color: randomColor({\n hue: lastSeriesColor.toHsv().h\n }).toRgbString(),\n stack: ''\n }\n\n addSeriesOption.type = addSeriesOption.chartType = chartType\n return addSeriesOption\n }\n\n private _selectTab(index: number) {\n this.configurer.setCurrentSeriesIndex(index)\n this.requestUpdate()\n }\n\n private _removeSeries(index: number) {\n this.configurer.removeSeries(index)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.requestUpdate()\n }\n\n private _addSeries() {\n const configurer = this.configurer\n\n if (!configurer.config.data.datasets) {\n return\n }\n\n const lastSeriesIndex = configurer.config.data.datasets.length\n const chartType = configurer.series.type || configurer.config.type\n const color = configurer.datasets[lastSeriesIndex - 1]?.backgroundColor\n const lastSeriesColor = new TinyColor(Array.isArray(color) ? color[0] : color)\n\n const seriesModel = this._getSeriesModel({\n chartType: chartType!,\n datasetsLength: lastSeriesIndex,\n lastSeriesColor\n })\n\n this.configurer.addSeries(seriesModel)\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.requestUpdate()\n }\n\n private _onWheelScroll(event: WheelEvent) {\n const tabContainer = this.seriesTabs\n if (tabContainer) {\n event.preventDefault()\n\n tabContainer.scrollLeft += event.deltaY\n\n this._onTabScroll()\n }\n }\n\n private _scrollLeft() {\n this._scrollTabContainer(-1)\n }\n\n private _scrollRight() {\n this._scrollTabContainer(1)\n }\n\n private _scrollTabContainer(direction: number) {\n const tabContainer = this.renderRoot!.querySelector<HTMLElement>('#series-tabs')\n if (tabContainer) {\n tabContainer.style.scrollBehavior = 'smooth'\n tabContainer.scrollLeft += direction * tabContainer.clientWidth\n }\n\n setTimeout(() => {\n tabContainer!.style.scrollBehavior = 'auto'\n this._onTabScroll()\n }, 300)\n }\n\n private _onTabScroll() {\n let tabContainer: HTMLElement | null | undefined\n let tabNavLeftButton: MdIcon\n let tabNavRightButton: MdIcon\n\n tabContainer = this.seriesTabs\n tabNavLeftButton = this.seriesTabNavLeftButton\n tabNavRightButton = this.seriesTabNavRightButton\n\n if (!tabContainer) {\n return\n }\n\n if (tabContainer.clientWidth == tabContainer.scrollWidth) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.setAttribute('disabled', '')\n } else if (tabContainer.scrollLeft <= 0) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.removeAttribute('disabled')\n } else if (tabContainer.scrollLeft + tabContainer.clientWidth >= tabContainer.scrollWidth) {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.setAttribute('disabled', '')\n } else {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.removeAttribute('disabled')\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './editors/index.js';
package/dist/src/index.js CHANGED
@@ -1,2 +1,3 @@
1
- "use strict";
1
+ /* never export ox-chart-js.js and ox-scichart.js to prevent chart.js version conflict */
2
+ export * from './editors/index.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,cAAc,oBAAoB,CAAA","sourcesContent":["/* never export ox-chart-js.js and ox-scichart.js to prevent chart.js version conflict */\nexport * from './editors/index.js'\n"]}
@@ -1,4 +1,5 @@
1
- import { LitElement } from 'lit';
1
+ import { LitElement, PropertyValues } from 'lit';
2
+ import type { OperatoChart } from '../../types/types.d.ts';
2
3
  declare global {
3
4
  interface Window {
4
5
  sciChartLoaded: boolean;
@@ -17,7 +18,7 @@ declare class OxSciChart extends LitElement {
17
18
  firstUpdated(): void;
18
19
  loadSciChart(): Promise<void>;
19
20
  initializeSciChart(): Promise<void>;
20
- updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
21
+ updated(changedProperties: PropertyValues<this>): Promise<void>;
21
22
  appendData(appendum: {
22
23
  [attr: string]: any;
23
24
  }[]): Promise<void>;
@@ -51,7 +51,7 @@ let OxSciChart = class OxSciChart extends LitElement {
51
51
  this.initializeSciChart();
52
52
  }
53
53
  async initializeSciChart() {
54
- const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {})) || {};
54
+ const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {}, this.data)) || {};
55
55
  this.chart = chart;
56
56
  this.dataSeries = dataSeries;
57
57
  this.updateDataSeries();
@@ -72,7 +72,7 @@ let OxSciChart = class OxSciChart extends LitElement {
72
72
  this.dataSeries.forEach(ds => ds.clear());
73
73
  const newData = this.dataSet;
74
74
  newData.forEach((data, index) => {
75
- const filteredData = data.filter(d => typeof d.yValue === 'number');
75
+ const filteredData = data.filter(d => typeof d.yValue === 'number' && !isNaN(d.yValue) && d.yValue !== null);
76
76
  if (filteredData.length > 0) {
77
77
  this.dataSeries[index].appendRange(filteredData.map(d => d.xValue), filteredData.map(d => d.yValue));
78
78
  }
@@ -97,9 +97,13 @@ let OxSciChart = class OxSciChart extends LitElement {
97
97
  console.error('Invalid date:', item[attrX]);
98
98
  return;
99
99
  }
100
+ const yValue = item[dataset.dataKey];
101
+ if (yValue === null || yValue === undefined) {
102
+ return;
103
+ }
100
104
  return {
101
105
  xValue: xValue.getTime() / 1000,
102
- yValue: item[dataset.dataKey]
106
+ yValue: yValue
103
107
  };
104
108
  })
105
109
  .filter(Boolean);
@@ -1 +1 @@
1
- {"version":3,"file":"ox-scichart.js","sourceRoot":"","sources":["../../../src/scichart/ox-scichart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAUrD,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAC8B,WAAM,GAAoC,IAAI,CAAA;QAC/C,SAAI,GAA8B,EAAE,CAAA;QAEvD,UAAK,GAAQ,IAAI,CAAA;QACjB,eAAU,GAAU,EAAE,CAAA;IA+HhC,CAAC;aA3HQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;GAiBlB,AAjBY,CAiBZ;IAED,YAAY;QACV,IAAI,CAAC,YAAY,EAAE,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBACnC,MAAM,CAAC,sBAAsB,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;oBAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC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,CAAC,IAAI,CAAC,EAAE;gBACV,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACtC,OAAM;gBACR,CAAC;gBAED,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;gBACpC,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;oBAC5B,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;oBAC3C,OAAM;gBACR,CAAC;gBAED,OAAO;oBACL,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI;oBAC/B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAQ,CAAC;iBAC/B,CAAA;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAyC,CAAA;QAC5D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,sDAAsD,CAAA;IACnE,CAAC;;AAlI2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA+C;AAC/C;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCAAqC;AAKvC;IAAvB,KAAK,CAAC,eAAe,CAAC;6CAA2B;AAP9C,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CAoIf","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport { buildSciChart } from './scichart-builder.js'\n\ndeclare global {\n interface Window {\n sciChartLoaded: boolean\n sciChartLoadingPromise: Promise<void>\n }\n}\n\n@customElement('ox-scichart')\nclass OxSciChart extends LitElement {\n @property({ type: Object }) config: OperatoChart.ChartConfig | null = null\n @property({ type: Array }) data: { [attr: string]: any }[] = []\n\n private chart: any = null\n private dataSeries: any[] = []\n\n @query('div#container') container!: HTMLDivElement\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chart-container {\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n .chart-content {\n flex: 1;\n position: relative;\n }\n `\n\n firstUpdated() {\n this.loadSciChart()\n }\n\n async loadSciChart() {\n if (!window.sciChartLoaded) {\n if (!window.sciChartLoadingPromise) {\n window.sciChartLoadingPromise = new Promise<void>(resolve => {\n const script = document.createElement('script')\n script.src = 'https://cdn.jsdelivr.net/npm/scichart/index.min.js'\n script.crossOrigin = 'anonymous'\n script.onload = () => {\n window.sciChartLoaded = true\n\n SciChart.SciChartSurface.UseCommunityLicense()\n\n resolve()\n }\n document.head.appendChild(script)\n })\n }\n\n await window.sciChartLoadingPromise\n }\n\n this.initializeSciChart()\n }\n\n async initializeSciChart() {\n const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {})) || {}\n\n this.chart = chart\n this.dataSeries = dataSeries!\n\n this.updateDataSeries()\n }\n\n async updated(changedProperties: Map<string | number | symbol, unknown>) {\n if (changedProperties.has('config') && this.config) {\n await this.initializeSciChart()\n }\n\n if (changedProperties.has('data')) {\n this.updateDataSeries()\n this.chart?.sciChartSurface.zoomExtents()\n }\n }\n\n async appendData(appendum: { [attr: string]: any }[]) {}\n\n updateDataSeries() {\n if (!this.dataSeries?.length) return\n\n this.dataSeries.forEach(ds => ds.clear())\n const newData = this.dataSet\n\n newData.forEach((data, index) => {\n const filteredData = data.filter(d => typeof d.yValue === 'number')\n\n if (filteredData.length > 0) {\n this.dataSeries[index].appendRange(\n filteredData.map(d => d.xValue),\n filteredData.map(d => d.yValue)\n )\n }\n })\n\n this.chart?.sciChartSurface.zoomExtents()\n this.chart?.sciChartSurface.invalidateElement()\n }\n\n get dataSet(): { xValue: number; yValue: number }[][] {\n const { config, data } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n\n if (!(data instanceof Array) || !attrX) {\n return []\n }\n\n return datasets.map(dataset => {\n return data\n .map(item => {\n if (!item || typeof item !== 'object') {\n return\n }\n\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return\n }\n\n return {\n xValue: xValue.getTime() / 1000,\n yValue: item[dataset.dataKey!]\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n })\n }\n\n render() {\n return html` <div id=\"container\" class=\"chart-container\"></div> `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ox-scichart': OxSciChart\n }\n}\n"]}
1
+ {"version":3,"file":"ox-scichart.js","sourceRoot":"","sources":["../../../src/scichart/ox-scichart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAWrD,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAC8B,WAAM,GAAoC,IAAI,CAAA;QAC/C,SAAI,GAA8B,EAAE,CAAA;QAEvD,UAAK,GAAQ,IAAI,CAAA;QACjB,eAAU,GAAU,EAAE,CAAA;IAoIhC,CAAC;aAhIQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;GAiBlB,AAjBY,CAiBZ;IAED,YAAY;QACV,IAAI,CAAC,YAAY,EAAE,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBACnC,MAAM,CAAC,sBAAsB,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;oBAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;oBAC/C,MAAM,CAAC,GAAG,GAAG,oDAA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C,GAAG,CAAC,OAAO,CAAC,EAAE;YAC5B,OAAO,IAAI;iBACR,GAAG,CAAC,IAAI,CAAC,EAAE;gBACV,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACtC,OAAM;gBACR,CAAC;gBAED,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;gBACpC,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;oBAC5B,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;oBAC3C,OAAM;gBACR,CAAC;gBAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAQ,CAAC,CAAA;gBACrC,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC5C,OAAM;gBACR,CAAC;gBAED,OAAO;oBACL,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI;oBAC/B,MAAM,EAAE,MAAM;iBACf,CAAA;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAyC,CAAA;QAC5D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,sDAAsD,CAAA;IACnE,CAAC;;AAvI2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA+C;AAC/C;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCAAqC;AAKvC;IAAvB,KAAK,CAAC,eAAe,CAAC;6CAA2B;AAP9C,UAAU;IADf,aAAa,CAAC,aAAa,CAAC;GACvB,UAAU,CAyIf","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit'\nimport { property, query, customElement } from 'lit/decorators.js'\nimport { buildSciChart } from './scichart-builder.js'\nimport type { OperatoChart } from '../../types/types.d.ts'\n\ndeclare global {\n interface Window {\n sciChartLoaded: boolean\n sciChartLoadingPromise: Promise<void>\n }\n}\n\n@customElement('ox-scichart')\nclass OxSciChart extends LitElement {\n @property({ type: Object }) config: OperatoChart.ChartConfig | null = null\n @property({ type: Array }) data: { [attr: string]: any }[] = []\n\n private chart: any = null\n private dataSeries: any[] = []\n\n @query('div#container') container!: HTMLDivElement\n\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n .chart-container {\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n .chart-content {\n flex: 1;\n position: relative;\n }\n `\n\n firstUpdated() {\n this.loadSciChart()\n }\n\n async loadSciChart() {\n if (!window.sciChartLoaded) {\n if (!window.sciChartLoadingPromise) {\n window.sciChartLoadingPromise = new Promise<void>(resolve => {\n const script = document.createElement('script')\n script.src = 'https://cdn.jsdelivr.net/npm/scichart/index.min.js'\n script.crossOrigin = 'anonymous'\n script.onload = () => {\n window.sciChartLoaded = true\n\n SciChart.SciChartSurface.UseCommunityLicense()\n\n resolve()\n }\n document.head.appendChild(script)\n })\n }\n\n await window.sciChartLoadingPromise\n }\n\n this.initializeSciChart()\n }\n\n async initializeSciChart() {\n const { chart, dataSeries } = (await buildSciChart(this.config, this.container, {}, this.data)) || {}\n\n this.chart = chart\n this.dataSeries = dataSeries!\n\n this.updateDataSeries()\n }\n\n async updated(changedProperties: PropertyValues<this>) {\n if (changedProperties.has('config') && this.config) {\n await this.initializeSciChart()\n }\n\n if (changedProperties.has('data')) {\n this.updateDataSeries()\n this.chart?.sciChartSurface.zoomExtents()\n }\n }\n\n async appendData(appendum: { [attr: string]: any }[]) {}\n\n updateDataSeries() {\n if (!this.dataSeries?.length) return\n\n this.dataSeries.forEach(ds => ds.clear())\n const newData = this.dataSet\n\n newData.forEach((data, index) => {\n const filteredData = data.filter(d => typeof d.yValue === 'number' && !isNaN(d.yValue) && d.yValue !== null)\n\n if (filteredData.length > 0) {\n this.dataSeries[index].appendRange(\n filteredData.map(d => d.xValue),\n filteredData.map(d => d.yValue)\n )\n }\n })\n\n this.chart?.sciChartSurface.zoomExtents()\n this.chart?.sciChartSurface.invalidateElement()\n }\n\n get dataSet(): { xValue: number; yValue: number }[][] {\n const { config, data } = this\n const { datasets = [], labelDataKey: attrX } = config?.data || {}\n\n if (!(data instanceof Array) || !attrX) {\n return []\n }\n\n return datasets.map(dataset => {\n return data\n .map(item => {\n if (!item || typeof item !== 'object') {\n return\n }\n\n const xValue = new Date(item[attrX])\n if (isNaN(xValue.getTime())) {\n console.error('Invalid date:', item[attrX])\n return\n }\n\n const yValue = item[dataset.dataKey!]\n if (yValue === null || yValue === undefined) {\n return\n }\n\n return {\n xValue: xValue.getTime() / 1000,\n yValue: yValue\n }\n })\n .filter(Boolean) as { xValue: number; yValue: number }[]\n })\n }\n\n render() {\n return html` <div id=\"container\" class=\"chart-container\"></div> `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ox-scichart': OxSciChart\n }\n}\n"]}
@@ -1,8 +1,9 @@
1
+ import type { OperatoChart } from '../../types/types.d.ts';
1
2
  export declare function buildSciChart(config: OperatoChart.ChartConfig | undefined | null, container: any, { fontSize, fontFamily, fontColor }: {
2
3
  fontSize?: number;
3
4
  fontFamily?: string;
4
5
  fontColor?: string;
5
- }): Promise<{
6
+ }, rawData?: any[]): Promise<{
6
7
  chart: any;
7
8
  dataSeries: any[];
8
9
  } | undefined>;
@@ -23,12 +23,34 @@ function calculatePrecision(stepSize = 1) {
23
23
  // 소수점이 없는 경우, precision은 0
24
24
  return 0;
25
25
  }
26
- export async function buildSciChart(config, container, { fontSize = 14, fontFamily = 'Roboto', fontColor }) {
26
+ export async function buildSciChart(config, container, { fontSize = 14, fontFamily = 'Roboto', fontColor }, rawData) {
27
27
  if (!config) {
28
28
  return;
29
29
  }
30
30
  const { SciChartSurface, SciChartJSLightTheme, SciChartJSDarkv2Theme, XyDataSeries, FastLineRenderableSeries, SplineLineRenderableSeries, FastColumnRenderableSeries, StackedColumnRenderableSeries, StackedMountainRenderableSeries, StackedColumnCollection, StackedMountainCollection, NumericAxis, DateTimeNumericAxis, ENumericFormat, EAutoRange, EAxisAlignment, ECoordinateMode, EHorizontalAnchorPoint, EVerticalAnchorPoint, NumberRange, MouseWheelZoomModifier, RubberBandXyZoomModifier, ZoomPanModifier, ZoomExtentsModifier, RolloverModifier, SmartDateLabelProvider, NumericLabelProvider, EllipsePointMarker, SquarePointMarker, TrianglePointMarker, CrossPointMarker, XPointMarker, WaveAnimation, LegendModifier, XAxisDragModifier, YAxisDragModifier, TextAnnotation, LineAnnotation, BoxAnnotation, HorizontalLineAnnotation, VerticalLineAnnotation } = SciChart;
31
+ // Helper 함수 - verticalAnchorPoint에 따라 적절한 y1 값을 반환
32
+ function getYPositionByAnchor(anchor) {
33
+ if (anchor === EVerticalAnchorPoint.Top) {
34
+ return 0.05; // 상단에서 5% 위치
35
+ }
36
+ else if (anchor === EVerticalAnchorPoint.Center) {
37
+ return 0.5; // 중앙
38
+ }
39
+ else if (anchor === EVerticalAnchorPoint.Bottom) {
40
+ return 0.95; // 차트 맨 아래
41
+ }
42
+ // 기본값 (Bottom이거나 값이 없는 경우)
43
+ return 0.95; // 바닥에서 5% 위치
44
+ }
45
+ // Helper 함수 - verticalAnchorPoint에 따라 적절한 좌표 모드 반환
46
+ function getYCoordModeByAnchor(anchor) {
47
+ // verticalAnchorPoint 값과 상관없이 상대 좌표 사용
48
+ return ECoordinateMode.Relative;
49
+ }
31
50
  class LocalTimeLabelProvider extends SmartDateLabelProvider {
51
+ constructor(options) {
52
+ super(options);
53
+ }
32
54
  formatLabel(value) {
33
55
  const date = new Date(value);
34
56
  try {
@@ -76,7 +98,7 @@ export async function buildSciChart(config, container, { fontSize = 14, fontFami
76
98
  xAxes.forEach((axis, index) => {
77
99
  const { axisTitle, ticks } = axis;
78
100
  const { autoMax, autoMin, min, max, stepSize, beginAtZero, color = fontColor, textStrokeColor = fontColor, display = !!axisTitle } = ticks || {};
79
- const labelProvider = new SmartDateLabelProvider({
101
+ const labelProvider = new LocalTimeLabelProvider({
80
102
  showWiderDateOnFirstLabel: true,
81
103
  showYearOnWiderDate: true,
82
104
  dateOffset: getLocalTimeOffset()
@@ -301,67 +323,207 @@ export async function buildSciChart(config, container, { fontSize = 14, fontFami
301
323
  : annotation.verticalAnchorPoint == 'Bottom'
302
324
  ? EVerticalAnchorPoint.Bottom
303
325
  : EVerticalAnchorPoint.Center;
304
- switch (annotation.type) {
305
- case 'text':
306
- sciAnnotation = new TextAnnotation({
307
- x1: annotation.x1,
308
- y1: annotation.y1,
309
- text: annotation.text,
310
- horizontalAnchorPoint,
311
- verticalAnchorPoint,
312
- fontSize: annotation.fontSize,
313
- fontFamily: annotation.fontFamily,
314
- textColor: convertColor(annotation.stroke, fontColor),
315
- xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
316
- yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
317
- });
318
- break;
319
- case 'line':
320
- sciAnnotation = new LineAnnotation({
321
- x1: annotation.x1,
322
- y1: annotation.y1,
323
- x2: annotation.x2,
324
- y2: annotation.y2,
325
- stroke: convertColor(annotation.stroke, '#FF0000'),
326
- strokeThickness: annotation.strokeThickness,
327
- xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
328
- yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
329
- });
330
- break;
331
- case 'box':
332
- sciAnnotation = new BoxAnnotation({
333
- x1: annotation.x1,
334
- y1: annotation.y1,
335
- x2: annotation.x2,
336
- y2: annotation.y2,
337
- fill: convertColor(annotation.fill, '#FF0000'),
338
- stroke: convertColor(annotation.stroke, '#FF0000'),
339
- strokeThickness: annotation.strokeThickness,
340
- xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
341
- yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
342
- });
343
- break;
344
- case 'horizontalLine':
345
- sciAnnotation = new HorizontalLineAnnotation({
346
- y1: annotation.y1,
347
- stroke: convertColor(annotation.stroke, '#FF0000'),
348
- strokeThickness: annotation.strokeThickness,
349
- xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
350
- yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
351
- });
352
- break;
353
- case 'verticalLine':
354
- sciAnnotation = new VerticalLineAnnotation({
355
- x1: annotation.x1,
356
- stroke: convertColor(annotation.stroke, '#FF0000'),
357
- strokeThickness: annotation.strokeThickness,
358
- xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
359
- yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
360
- });
361
- break;
362
- default:
363
- console.error('Unknown annotation type:', annotation.type);
364
- break;
326
+ // dataKey가 있는 경우 데이터와 연동
327
+ if (annotation.dataKey && rawData && rawData.length > 0) {
328
+ const attrX = fromData?.labelDataKey || ''; // X축 데이터 키 가져오기
329
+ if (annotation.type === 'verticalLine') {
330
+ // 수직 라인: falsy => truthy 변화 지점에만 표시
331
+ let prevFalsy = true; // 초기값을 true로 설정하여 첫 값이 truthy면 포함
332
+ for (let i = 0; i < rawData.length; i++) {
333
+ // 원본 데이터에서 직접 값 가져오기
334
+ const currentValue = rawData[i][annotation.dataKey];
335
+ const isTruthy = !!currentValue;
336
+ if (isTruthy && prevFalsy) {
337
+ // falsy에서 truthy로 변화한 지점
338
+ // X 값은 인덱스나 타임스탬프 사용
339
+ const xValue = attrX ? new Date(rawData[i][attrX]).getTime() / 1000 : i;
340
+ // 수직선 추가
341
+ const sciVerticalLine = new VerticalLineAnnotation({
342
+ x1: xValue,
343
+ stroke: convertColor(annotation.stroke, '#FF0000'),
344
+ strokeThickness: annotation.strokeThickness,
345
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
346
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
347
+ });
348
+ sciChartSurface.annotations.add(sciVerticalLine);
349
+ // 텍스트 레이블 추가
350
+ if (annotation.text !== undefined || currentValue !== undefined) {
351
+ // 표시할 텍스트 결정
352
+ const labelText = annotation.text || `${annotation.dataKey}: ${currentValue}`;
353
+ // 텍스트 주석 추가 (수직선 상단에)
354
+ const sciTextAnnotation = new TextAnnotation({
355
+ // 동일한 X 위치 사용
356
+ x1: xValue,
357
+ // verticalAnchorPoint에 따라 Y 위치 결정
358
+ y1: getYPositionByAnchor(annotation.verticalAnchorPoint),
359
+ text: labelText,
360
+ // 가운데 정렬
361
+ horizontalAnchorPoint: annotation.horizontalAnchorPoint || EHorizontalAnchorPoint.Center,
362
+ // 텍스트의 하단이 y1에 위치
363
+ verticalAnchorPoint: annotation.verticalAnchorPoint || EVerticalAnchorPoint.Bottom,
364
+ fontFamily: annotation.fontFamily || fontFamily,
365
+ fontSize: annotation.fontSize || 14,
366
+ textColor: convertColor(annotation.stroke, '#FF0000'),
367
+ background: 'rgba(255, 255, 255, 0.7)', // 텍스트 배경 추가
368
+ padding: { left: 5, top: 5, right: 5, bottom: 5 }, // 패딩 추가
369
+ xCoordinateMode: ECoordinateMode.DataValue,
370
+ // verticalAnchorPoint에 따라 좌표 모드 결정
371
+ yCoordinateMode: getYCoordModeByAnchor(annotation.verticalAnchorPoint)
372
+ });
373
+ sciChartSurface.annotations.add(sciTextAnnotation);
374
+ }
375
+ }
376
+ prevFalsy = !isTruthy;
377
+ }
378
+ // 기본 annotation 처리 건너뛰기
379
+ return;
380
+ }
381
+ else if (annotation.type === 'text') {
382
+ // 텍스트: 해당 값을 그대로 출력
383
+ for (let i = 0; i < rawData.length; i++) {
384
+ // 원본 데이터에서 직접 값 가져오기
385
+ const value = rawData[i][annotation.dataKey];
386
+ // null이나 undefined가 아닌 값만 표시
387
+ if (value !== undefined && value !== null) {
388
+ // X 값은 인덱스나 타임스탬프 사용
389
+ const xValue = attrX ? new Date(rawData[i][attrX]).getTime() / 1000 : i;
390
+ const sciTextAnnotation = new TextAnnotation({
391
+ x1: xValue,
392
+ y1: value,
393
+ text: String(value),
394
+ horizontalAnchorPoint,
395
+ verticalAnchorPoint,
396
+ fontSize: annotation.fontSize,
397
+ fontFamily: annotation.fontFamily,
398
+ textColor: convertColor(annotation.stroke, fontColor),
399
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
400
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
401
+ });
402
+ sciChartSurface.annotations.add(sciTextAnnotation);
403
+ }
404
+ }
405
+ // 기본 annotation 처리 건너뛰기
406
+ return;
407
+ }
408
+ else {
409
+ // 다른 타입의 annotation은 원래 로직으로 처리
410
+ // 원본 데이터에서 값 추출
411
+ const dataValues = rawData.map(item => item[annotation.dataKey]).filter(v => v !== undefined);
412
+ if (dataValues.length > 0) {
413
+ // annotation 타입에 따라 데이터 값을 적용
414
+ if (annotation.type === 'horizontalLine') {
415
+ annotation.y1 = dataValues[0];
416
+ }
417
+ else if (annotation.type === 'line' || annotation.type === 'box') {
418
+ // 데이터 값이 최소 한 개 이상인 경우에만 적용
419
+ if (annotation.yCoordinateMode === 'DataValue') {
420
+ annotation.y1 = dataValues[0];
421
+ }
422
+ if (annotation.xCoordinateMode === 'DataValue' && !annotation.x1) {
423
+ annotation.x1 = 0;
424
+ }
425
+ // 두 번째 지점이 필요한 경우 (line, box)
426
+ if (dataValues.length > 1) {
427
+ if (annotation.yCoordinateMode === 'DataValue') {
428
+ annotation.y2 = dataValues[dataValues.length - 1];
429
+ }
430
+ if (annotation.xCoordinateMode === 'DataValue' && !annotation.x2) {
431
+ annotation.x2 = dataValues.length - 1;
432
+ }
433
+ }
434
+ }
435
+ }
436
+ }
437
+ }
438
+ else {
439
+ // 기본 annotation 생성 (dataKey가 없거나 rawData가 없는 경우)
440
+ switch (annotation.type) {
441
+ case 'text':
442
+ sciAnnotation = new TextAnnotation({
443
+ x1: annotation.x1,
444
+ y1: annotation.y1,
445
+ text: annotation.text,
446
+ horizontalAnchorPoint,
447
+ verticalAnchorPoint,
448
+ fontSize: annotation.fontSize,
449
+ fontFamily: annotation.fontFamily,
450
+ textColor: convertColor(annotation.stroke, fontColor),
451
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
452
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
453
+ });
454
+ break;
455
+ case 'line':
456
+ sciAnnotation = new LineAnnotation({
457
+ x1: annotation.x1,
458
+ y1: annotation.y1,
459
+ x2: annotation.x2,
460
+ y2: annotation.y2,
461
+ stroke: convertColor(annotation.stroke, '#FF0000'),
462
+ strokeThickness: annotation.strokeThickness,
463
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
464
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
465
+ });
466
+ break;
467
+ case 'box':
468
+ sciAnnotation = new BoxAnnotation({
469
+ x1: annotation.x1,
470
+ y1: annotation.y1,
471
+ x2: annotation.x2,
472
+ y2: annotation.y2,
473
+ fill: convertColor(annotation.fill, '#FF0000'),
474
+ stroke: convertColor(annotation.stroke, '#FF0000'),
475
+ strokeThickness: annotation.strokeThickness,
476
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
477
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
478
+ });
479
+ break;
480
+ case 'horizontalLine':
481
+ sciAnnotation = new HorizontalLineAnnotation({
482
+ y1: annotation.y1,
483
+ stroke: convertColor(annotation.stroke, '#FF0000'),
484
+ strokeThickness: annotation.strokeThickness,
485
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
486
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
487
+ });
488
+ break;
489
+ case 'verticalLine':
490
+ sciAnnotation = new VerticalLineAnnotation({
491
+ x1: annotation.x1,
492
+ stroke: convertColor(annotation.stroke, '#FF0000'),
493
+ strokeThickness: annotation.strokeThickness,
494
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
495
+ yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
496
+ });
497
+ // 텍스트가 있는 경우에만 텍스트 주석 추가
498
+ if (annotation.text) {
499
+ // 수직선을 먼저 추가
500
+ if (sciAnnotation) {
501
+ sciChartSurface.annotations.add(sciAnnotation);
502
+ }
503
+ // 텍스트 주석 생성
504
+ const textAnnotation = new TextAnnotation({
505
+ x1: annotation.x1,
506
+ y1: getYPositionByAnchor(annotation.verticalAnchorPoint),
507
+ text: annotation.text,
508
+ horizontalAnchorPoint: annotation.horizontalAnchorPoint || EHorizontalAnchorPoint.Center,
509
+ verticalAnchorPoint: annotation.verticalAnchorPoint || EVerticalAnchorPoint.Bottom,
510
+ fontFamily: annotation.fontFamily || fontFamily,
511
+ fontSize: annotation.fontSize || 14,
512
+ textColor: convertColor(annotation.stroke, '#FF0000'),
513
+ background: 'rgba(255, 255, 255, 0.7)', // 텍스트 배경 추가
514
+ padding: { left: 5, top: 5, right: 5, bottom: 5 }, // 패딩 추가
515
+ xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
516
+ yCoordinateMode: getYCoordModeByAnchor(annotation.verticalAnchorPoint)
517
+ });
518
+ // 텍스트 주석 추가
519
+ sciChartSurface.annotations.add(textAnnotation);
520
+ sciAnnotation = null; // 이미 추가했으므로 아래에서 다시 추가하지 않도록 null로 설정
521
+ }
522
+ break;
523
+ default:
524
+ console.error('Unknown annotation type:', annotation.type);
525
+ break;
526
+ }
365
527
  }
366
528
  if (sciAnnotation) {
367
529
  sciChartSurface.annotations.add(sciAnnotation);