forked from OCA/web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
89 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# generated from manifests external_dependencies | ||
plotly==5.13.1 |
1 change: 1 addition & 0 deletions
1
setup/web_widget_plotly_chart/odoo/addons/web_widget_plotly_chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../web_widget_plotly_chart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
web_widget_plotly_chart/static/src/js/widget_plotly.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** @odoo-module **/ | ||
|
||
import {loadJS} from "@web/core/assets"; | ||
import {registry} from "@web/core/registry"; | ||
|
||
import {Component, onPatched, onWillStart, useEffect, useRef} from "@odoo/owl"; | ||
|
||
export class PlotlyChartWidgetField extends Component { | ||
setup() { | ||
this.divRef = useRef("plotly"); | ||
|
||
onWillStart(async () => { | ||
await loadJS( | ||
"/web_widget_plotly_chart/static/src/lib/plotly/plotly-2.18.2.min.js" | ||
); | ||
this.updatePlotly(this.props.value); | ||
}); | ||
|
||
onPatched(() => { | ||
this.updatePlotly(this.props.value); | ||
}); | ||
|
||
useEffect(() => { | ||
this.updatePlotly(this.props.value); | ||
}); | ||
} | ||
updatePlotly(value) { | ||
const value_html = $(value); | ||
const div = value_html.find(".plotly-graph-div").get(0).outerHTML || ""; | ||
const script = value_html.find("script").get(0).textContent || ""; | ||
|
||
if (this.divRef.el) { | ||
this.divRef.el.innerHTML = div; | ||
new Function(script)(); | ||
} | ||
} | ||
} | ||
|
||
PlotlyChartWidgetField.template = "web_widget_plotly_chart.PlotlyChartWidgetField"; | ||
PlotlyChartWidgetField.supportedTypes = ["char", "text"]; | ||
|
||
registry.category("fields").add("plotly_chart", PlotlyChartWidgetField); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="web_widget_plotly_chart.PlotlyChartWidgetField" owl="1"> | ||
<div t-ref="plotly" /> | ||
</t> | ||
|
||
</templates> |
8 changes: 8 additions & 0 deletions
8
web_widget_plotly_chart/static/src/lib/plotly/plotly-2.18.2.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 0 additions & 65 deletions
65
web_widget_plotly_chart/static/src/lib/plotly/plotly-2.7.0.min.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.