Problem with curved lines in Teechart JavaScript

I am looking to create smoothed lines for my chart. I used teechart.js to make a chart, but it is not working well. Here is an image comparison: the left image is mine and I would like to achieve the smooth line on the right. See example here

<!DOCTYPE html>
    <html lang="en">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

            <title>Chart</title>

            <script src="./js/three.min.js" type="text/javascript"></script>

            <script src="./js/Detector.js" type="text/javascript"></script>
            <script src="./js/TrackballControls.js" type="text/javascript"></script>

            <script src="./js/helvetiker_regular.typeface.js"></script>

            <script src="./js/teechart.js" type="text/javascript"></script>
            <script src="./js/teechart-3d.js" type="text/javascript"></script>

            <script type="text/javascript">
            "use strict";
            var three1, Chart1;

            function draw() {
                three1 = new Tee.Three("canvas1");
                three1.setShowShadows(true);

                Chart1 = new Tee.Chart(three1); 
                Chart1.addSeries(new Tee.Line([80,70,60,50,40,30,40,50,60,70,80,90] , 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(',')));
                Chart1.addSeries(new Tee.Line([10,20,30,40,50,60,70,60,50,40,30,20]));
                Chart1.title.text="";
                Chart1.footer.text="";
                Chart1.legend.visible = false;
                Chart1.walls.back.size=0.2;
                Chart1.walls.left.size=10;
                Chart1.walls.bottom.size=10;
                Chart1.walls.back.format.transparency=0.2;
                Chart1.bounds.x = -100; 
                Chart1.bounds.y = 50;
                Chart1.bounds.width = 900;
                Chart1.bounds.height = 400;
                Chart1.axes.left.setMinMax(0, 120);

                if (three1.isEnabled()) {
                    Chart1.draw();
                    animate1();
                } else {
                    // Show message (WebGL not available) :
                    Detector.addGetWebGLMessage();

                    // Disable WebGL and use HTML5 2D Canvas:
                    three1.setEnabled(false, Chart1);
                }

                // Loop
                function animate1() {
                    three1.update();
                    requestAnimationFrame(animate1);
                }

            }

    </script>
        </head>

        <body onload="draw()">
            <canvas id="canvas1" style="width: 700px; height: 500px; display: inline; background: white;" width="800" height="500"></canvas>
        </body>
    </html>

I look forward to your helpful responses.

Answer №1

After reviewing your code, I noticed a few missing details that once corrected, the code runs smoothly:

  • To set smoothed lines in your example, use the following code:

    Chart1.series.items[0].smooth = 0.5;
    Chart1.series.items[1].smooth = 0.5;
    
  • Make sure to include teechart-extras.js to define Tee.drawSpline. Include it like this:

    <script src="./js/teechart-extras.js" type="text/javascript"></script>
    

Answer №2

If you're looking to create a tube using a spline or curve as a path, take a look at the THREE.TubeGeometry feature:

extrudePath = // define your spline or curve here;
segments = 64;
radius = 5;
radiusSegments = 8;
closed = false;
tube = new THREE.TubeGeometry(extrudePath, segments, radius, radiusSegments, closed);
mesh = new THREE.Mesh(tube, material);

scene.add(mesh);

For more examples and inspiration, check out some demos here

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Both the complete and success functions are not triggering simultaneously

When I try to use both success and complete together, it seems to not be working properly. If I omit dataType: "jsonp", then the success function works fine, but including it causes only the complete function to work. var reRank = false; function reAss ...

Why do Material UI components fail to render in jsdom while using Jest?

During my UI testing using Jest/React Testing Library, I encountered a peculiar issue. In one of my components, the return statement is structured as follows: const sidebarContentUp = ( <Drawer anchor="left" onClose={onMobileC ...

The progress event of the XMLHttpRequest updates quickly, outpacing the speed of the upload itself

I've been working on setting up an upload form and using xhr to return the upload status to the user. Everything seems to be in place, but I'm facing a strange issue where the callbacks are happening too quickly and showing a higher percentage th ...

Having trouble with changing the state within an AngularJS (Ionic Framework) controller?

My goal is to switch views within the Search controller after receiving search results from the server through $http. However, my current approach doesn't seem to be working as intended. I also need to pass the response to the new view for displaying ...

GraphQL is not capable of fetching data directly from a mysql database

Trying to incorporate GraphQL with MySQL in a Node.js Express server has been my recent challenge. Unfortunately, every time I execute my query, an error surfaces. Here is the specific error message: { "errors": [ { "message&quo ...

Error encountered on MongoDB with code E11000 due to duplicate key in array field

Hey there, I have a question regarding mongoose schema. Here is the code snippet: . So, I attempted to create a document without the "work" property. It worked the first time I tried it, but when I repeated the same action, it didn't work as expected. ...

The context of the Nuxt.js3 plugin loses its definition

Currently, I am working on a project that involves Nuxt.js3 and supabase integration. In my plugins/supabase.server.js file (I am still unsure whether using server or client is the best approach), I want to call "supabase = createClient(~~)" from index.vu ...

There seems to be a lack of update in the fragment shader due to mouse movement

Struggling to incorporate the Voronoi shader from the Book of Shaders into three.js, I can't figure out why the mouse position isn't affecting my visible output. Even though I'm logging the mouse position and checking that the uniform value ...

Could you please explain the significance of scope: [variable-name]='@' in Angular?

I absolutely despise asking what may seem like foolish questions, however, it seems that the AngularJS documentation authors have left out some crucial clarifications. When constructing a directive, you have the ability to connect variables within your di ...

Transforming a detailed JSON structure into a more simplified format with Angular 2

As a newcomer to Angular 2, I find myself encountering a hurdle in filtering unnecessary data from a JSON object that is retrieved from a REST API. Below is an example of the JSON data I am working with: { "refDataId":{ "rdk":1, "refDataTy ...

The interaction between a JavaScript function call and C# is not functioning properly

Attempting to invoke the JavaScript function from CodeBehind ( C# ) : function scrollToBottom() { window.scrollTo(0, document.body.scrollHeight); } The function successfully executes when directly called from my asp.net application. However, ...

Inject a dynamic URL parameter into an iframe without the need for server-side scripting

I'm really stuck and could use some assistance with the following issue, as I am unable to solve it on my own :( When a user is redirected to a form (provided via an iframe), there is a dynamic URL involved: website.com/form?id=123 The code resp ...

Is there a way to modify a website's layout by injecting custom JavaScript code to adjust the width of a specific pane or section

I want to enhance my browsing experience by manipulating the width of a pane using a JavaScript code injected through Google Chrome. My goal is to save this code as a bookmark so that whenever I click on it, the changes will be applied to the website. Manu ...

Collaborative Artistry: Using HTML5, JavaScript, and Node.js for Multiplayer

Creating a multiplayer drawing application for touch-enabled devices has been a challenge. I have utilized Node.js with Socket.io to draw points on a canvas, but there's an issue with the touchend event not resetting properly. To illustrate, take a l ...

Oops! There was a validation error as the duration was not formatted as a number. Please make sure to provide a valid numerical value for the duration field

When attempting to update data from a MongoDB database and checking the results on Postman, an error is encountered. The error reads as follows: "Error: ValidationError: duration: Cast to Number failed for value \"NaN\" at path \"duration&bs ...

Is it possible for Yarn to fail to include both ESM and CJS versions of a package during publishing or adding?

Our application is equipped with Parcel and utilizes a UI library consisting of react components. This UI library is built with Rollup and is privately published on NPM. I've been attempting to transition our application to Parcel 2, but I'm fac ...

Using regular expressions to replace all special characters, excluding dots

$('#price').keyup(function(){ $('#price').val($('#price').val().replace(/[_\W]+/g, "-")); }) Experience it firsthand here: http://jsfiddle.net/2KRHh/6/. In the scenario above, special characters are eliminated. ...

The request header fails to function properly when used for cross-domain Ajax requests

I'm facing a challenge with adding a parameter in the request header. It works smoothly for calls within the same domain, but when making a call to a different domain (the API), I need to adjust the header parameter itself. Here is the snippet of cod ...

The function JSON.parse appears to be malfunctioning within the code, yet it operates smoothly when executed in

I am facing an issue with my Angular $http post service that communicates with a WCF service. The success handler in the http post is as follows: .success(function (data) { var response = JSON.parse(data); var tsValid = response.Outcome; defer ...

Processing message received from Node JS Server

Currently, I am working on a project that involves compiling a specific Java file on the server side. In case there are any errors during compilation, I aim to capture the error information and relay it back to the client side. However, despite trying vari ...