CloudOrc / SolidUI

one sentence generates any graph
https://cloudorc.github.io/SolidUI-Website/
Apache License 2.0
573 stars 86 forks source link

[Feature][SolidUI] Dev0.3.0 Business test List #130

Closed dlimeng closed 1 year ago

dlimeng commented 1 year ago

Search before asking

Problem Description

prompt: 提供一个使用D3.js库生成柱状图的HTML代码片段

<DOCTYPE html>
<html>
<head>
    <title>D3.js Bar Chart</title>
    <script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
    <script>
        var data = [
            {"x": "A", "y": 5},
            {"x": "B", "y": 8},
            {"x": "C", "y": 12},
            {"x": "D", "y": 6},
            {"x": "E", "y": 15},
            {"x": "F", "y": 10}
        ];

        var margin = {top: 20, right: 20, bottom: 30, left: 40},
            width = 600 - margin.left - margin.right,
            height = 400 - margin.top - margin.bottom;

        var x = d3.scaleBand()
            .range([0, width])
            .padding(0.1);

        var y = d3.scaleLinear()
            .range([height, 0]);

        var svg = d3.select("body").append("svg")
            .attr("width", width + margin.left + margin.right)
            .attr("height", height + margin.top + margin.bottom)
            .append("g")
            .attr("transform",
                "translate(" + margin.left + "," + margin.top + ")");

        x.domain(data.map(function(d) { return d.x; }));
        y.domain([0, d3.max(data, function(d) { return d.y; })]);

        svg.selectAll(".bar")
            .data(data)
            .enter().append("rect")
            .attr("class", "bar")
            .attr("x", function(d) { return x(d.x); })
            .attr("width", x.bandwidth())
            .attr("y", function(d) { return y(d.y); })
            .attr("height", function(d) { return height - y(d.y); });

        svg.append("g")
            .attr("transform", "translate(0," + height + ")")
            .call(d3.axisBottom(x));

        svg.append("g")
            .call(d3.axisLeft(y));
    </script>
</body>
</html>

prompt : 提供一个使用echarts库生成柱状图的HTML代码片段

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>柱状图</title>
  <script src="https://cdn.jsdelivr.net/npm/echarts@5.0.1/dist/echarts.min.js"></script>
</head>
<body>
  <div id="chart" style="width: 600px;height:400px;"></div>
  <script>
    var chart = echarts.init(document.getElementById('chart'));
    var option = {
      xAxis: {
        type: 'category',
        data: ['A', 'B', 'C', 'D', 'E', 'F']
      },
      yAxis: {
        type: 'value'
      },
      series: [{
        data: [5, 8, 12, 6, 15, 10],
        type: 'bar'
      }]
    };
    chart.setOption(option);
  </script>
</body>
</html>
image

参考生成python code 方式保存

image image image

Description

No response

Use case

No response

Solutions

No response

Anything else

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

:blush: Welcome to the SolidUI community!! We are glad that you are contributing by opening this issue.

Please make sure to include all the relevant context. We will be here shortly.

If you are interested in contributing to our project, please let us know! You can check out our contributing guide on :point_right: How to Contribute.

If you have any questions or suggestions, please feel free to post them here or contact us via email at mengyoupanshan@gmail.com.

We appreciate your interest in SolidUI and look forward to working with you!