Skip to content

Commit 0cef08c

Browse files
committedNov 11, 2024
fixed hillchart for lowcoder-cli-template
1 parent 68f3939 commit 0cef08c

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed
 

‎client/packages/lowcoder-cli-template-typescript/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lowcoder-cli-template-typescript",
3-
"version": "0.0.20",
3+
"version": "0.0.21",
44
"type": "module",
55
"scripts": {
66
"start": "NODE_OPTIONS=--max_old_space_size=6144 vite",
@@ -22,7 +22,9 @@
2222
}
2323
},
2424
"dependencies": {
25+
"@observablehq/inspector": "^5.0.1",
2526
"@observablehq/runtime": "^4.8.2",
27+
"@observablehq/stdlib": "^5.8.8",
2628
"@types/react": "^18.2.45",
2729
"@types/react-dom": "^18.2.18",
2830
"lowcoder-cli": "^0.0.30",

‎client/packages/lowcoder-cli-template-typescript/src/vendors/Chart.jsx

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import React from 'react';
22
import PropTypes from 'prop-types'
3-
import { Runtime, Inspector } from '@observablehq/runtime';
3+
import { Runtime } from '@observablehq/runtime';
4+
import { Inspector } from "@observablehq/inspector";
5+
import { Library } from "@observablehq/stdlib";
6+
7+
const library = new Library();
48

59
function Chart(props) {
610
const [chartRef, setChartRef] = React.useState();
@@ -16,21 +20,20 @@ function Chart(props) {
1620
main.variable().define('translateXtoY', function() {
1721
return x => 50 * Math.sin((Math.PI / 50) * x - (1 / 2) * Math.PI) + 50;
1822
});
19-
main.variable().define('d3', ['require'], function(require) {
20-
return require('https://d3js.org/d3.v5.min.js');
23+
main.variable().define('d3', [], function() {
24+
return Library.require('https://d3js.org/d3.v5.min.js');
2125
});
2226

2327
// Define the HillChart class
24-
main.variable().define('HillChart', ['d3', 'DOM', 'translateXtoY'], function(d3, DOM, translateXtoY) {
28+
main.variable().define('HillChart', ['d3', 'translateXtoY'], function(d3, translateXtoY) {
2529
return class HillChart {
2630
constructor(chart_height, chart_width, items) {
2731
this.chart_height = chart_height;
2832
this.chart_width = chart_width;
2933
this.items = items;
30-
31-
this.svg = d3.select(DOM.svg(this.chart_width, this.chart_height)).attr('viewBox', `-20 -20 ${this.chart_width + 80} ${this.chart_height + 20}`);
34+
35+
this.svg = d3.select(library.DOM.svg(this.chart_width, this.chart_height)).attr('viewBox', `-20 -20 ${this.chart_width + 80} ${this.chart_height + 20}`);
3236
}
33-
3437

3538
render() {
3639
const xScale = d3

‎client/yarn.lock

+23-1
Original file line numberDiff line numberDiff line change
@@ -3164,6 +3164,15 @@ __metadata:
31643164
languageName: node
31653165
linkType: hard
31663166

3167+
"@observablehq/inspector@npm:^5.0.1":
3168+
version: 5.0.1
3169+
resolution: "@observablehq/inspector@npm:5.0.1"
3170+
dependencies:
3171+
isoformat: ^0.2.0
3172+
checksum: a3e93a5559eaefee498e810864c36830147df59d11fd32054b0bf088a7d0a83de494617c900bb1f6680ce70e378a4c7fdc56aff7baf3f59f049dafbe442cc77a
3173+
languageName: node
3174+
linkType: hard
3175+
31673176
"@observablehq/runtime@npm:^4.8.2":
31683177
version: 4.28.0
31693178
resolution: "@observablehq/runtime@npm:4.28.0"
@@ -3184,6 +3193,17 @@ __metadata:
31843193
languageName: node
31853194
linkType: hard
31863195

3196+
"@observablehq/stdlib@npm:^5.8.8":
3197+
version: 5.8.8
3198+
resolution: "@observablehq/stdlib@npm:5.8.8"
3199+
dependencies:
3200+
d3-array: ^3.2.0
3201+
d3-dsv: ^3.0.1
3202+
d3-require: ^1.3.0
3203+
checksum: 0da51131dc49bd356d363838aa4f2631fbb87acef217c9d73cb54f641c5f54a7359dff67bb94916db52cf6ad8b0ffef526e548eeac3e2a908455d9eb7c889256
3204+
languageName: node
3205+
linkType: hard
3206+
31873207
"@pkgjs/parseargs@npm:^0.11.0":
31883208
version: 0.11.0
31893209
resolution: "@pkgjs/parseargs@npm:0.11.0"
@@ -8213,7 +8233,7 @@ coolshapes-react@lowcoder-org/coolshapes-react:
82138233
languageName: node
82148234
linkType: hard
82158235

8216-
"d3-dsv@npm:1 - 3, d3-dsv@npm:3":
8236+
"d3-dsv@npm:1 - 3, d3-dsv@npm:3, d3-dsv@npm:^3.0.1":
82178237
version: 3.0.1
82188238
resolution: "d3-dsv@npm:3.0.1"
82198239
dependencies:
@@ -13694,7 +13714,9 @@ coolshapes-react@lowcoder-org/coolshapes-react:
1369413714
version: 0.0.0-use.local
1369513715
resolution: "lowcoder-cli-template-typescript@workspace:packages/lowcoder-cli-template-typescript"
1369613716
dependencies:
13717+
"@observablehq/inspector": ^5.0.1
1369713718
"@observablehq/runtime": ^4.8.2
13719+
"@observablehq/stdlib": ^5.8.8
1369813720
"@types/react": ^18.2.45
1369913721
"@types/react-dom": ^18.2.18
1370013722
lowcoder-cli: ^0.0.30

0 commit comments

Comments
 (0)