Tutorial on creating a subset of a series using jqplot

I am looking to display three series on the same canvas. The series are defined as follows:

rec1 = [0,  0,   150, 200, 0  ];
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];

Below are the source codes I am using to draw these series.

$.jqplot("chart", [rec1, rec2, rec3], {
    title: "",
    axesDefaults: {
        tickRenderer: $.jqplot.CanvasAxisTickRenderer,
        tickOptions: {
            fontSize: '10pt'
        }
    },
    seriesDefaults: {
        rendererOptions: {
            smooth: false
        },
        pointLabels: {
            show: true,
            ypadding: 10
        },
        showMarker: true,
        lineWidth: 2
    },
    legend: {
        show: true,
        location: 'nw',
        placement: "outside"
    }
});

In rec1, any elements with a zero value should remain zero. However, I want to hide these zero-value-elements in rec1. Is there a way to achieve this? Setting rec1 to be:

rec1 = [undefined, undefined, 150, 200, undefined]

Will hide these undefined points, but it causes the point labels for 150 and 200 to appear at incorrect positions, as shown in the image. Appreciate any helpful guidance.

Answer №1

To ensure proper placement of your points, it is recommended to use a 2-dimensional array instead of a "flat" array:

rec1 = [[3, 150], [4, 200] ]; // defining 2 points with (x, y) coordinates
rec2 = [60, 120, 179, 240, 300];
rec3 = [50, 100, 150, 200, 250];

I have created a jsfiddle demonstration to illustrate this concept. I have slightly adjusted the position of the point [3, 150] to [3, 90] in order to show its correct label placement: http://jsfiddle.net/5wgcqyet/1/

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

Encountering Challenges when Implementing Next.js with Jest

When attempting to run a test in next.js using jest, an error keeps appearing: The issue may be due to the wrong test environment being used. Refer to https://jestjs.io/docs/configuration#testenvironment-string for more information. Consider utilizing the ...

Error: Chrome is preventing an AJAX request

Hello everyone, I have been facing an interesting issue with my Ajax request. It seems to work perfectly fine in Internet Explorer, which is quite surprising. However, when I attempt to run the same code in Chrome, I encounter the following error: XMLHt ...

Retrieving user information from the database and adding it to the specified element

I've been grappling with what seems like a simple question for the past hour. Below is a script that I have which pulls all active reservations from the reservations table. require("../includes/connect.php"); function dispAllReservations(){ $i= ...

Steps to manage the time delay between mousewheel events triggering

Currently, I am working on a website for a movie production company that showcases their various films in full-screen mode. Each video is listed and there is a function that automatically takes the user to the next video when a mousewheel event occurs. How ...

Verify whether the type of the emitted variable aligns with the specified custom type

Currently, I am in the process of testing Vue 3 components using jest. My main objective is to receive an emit when a button is clicked and then verify if the emitted object corresponds to a custom type that I have defined in a separate file. Below is an e ...

Unable to sign up for WordPress function

I'm having trouble getting my function registered properly in WordPress, no matter how many times I try. So far, here's what I've done: Inserted code into themes functions.php function test_my_script() { wp_register_script( 'custom-s ...

Validating decimals in a text field with either JavaScript or jQuery

I need to implement text field validation on the keyup event. The text field should only accept money type decimals such as: (12.23) (.23) (0.26) (5.09) (6.00) If any incorrect value is entered, it should revert back to the previous value and remove the ...

Ways to automatically include a local variable in all functions

In each of my functions, I start with this specific line: var local = {} By doing so, it allows me to organize my variables using the following structure: local.x = 1 local.y = 2 Is there a way to modify all function prototypes to automatically include ...

Issue with delayed chaining of class addition and removal in JQuery not functioning as expected

Here is the code snippet: $(document).ready(function () { $('.current-visitors').delay(3000).queue(function () { $(this).addClass('show').delay(1000).queue(function () { $(this).removeClass('sho ...

Create a link for editing in a data table that can filter based on multiple column values and also enable global search on specific custom

How can I generate an edit link with a function that requires multiple parameters extracted from different data columns received via ajax? I have come across the render callback, but it seems to only return one column value at a time and my requirement is ...

The setInterval function is active in various components within Angular 6

Recently, I started using Angular(6) and incorporated the setInterval function within a component. It's functioning properly; however, even after navigating to another route, the setInterval continues to run. Can someone help me determine why this is ...

Trouble with X-editable linking to database for updates

Utilizing the X-Editable plugin within my PHP application to update fields in a table and utilizing a POST file to update the database. Below is the form code: <table id="restaurant" class="table table-bordered table-striped"> <tbody> ...

Does D3 iterate through the entire array every time we define a new callback?

It seems that every time a callback is set, d3 loops through the entire array. Initially, I thought that functions like attr() or each() were added to a pipeline and executed all at once later on. I was trying to dynamically process my data within d3&apo ...

What is the process for dynamically setting @click in vue.js?

My array contains objects with methods as actions from a vue object. How can I dynamically set the @click event in a v-for loop? I attempted to use this.m1, "this.m1", "m1", but encountered an error: fns.apply is not a function. Javascript: new Vue ...

Tips for accessing the value and text of an Angular Material mat-select through the use of *ngFor

When using a dropdown menu, I want to retrieve both the value and text of the selected option. View dropdown image Underneath the dropdown menu, I aim to display values in the format of "options: 'value' - 'selected option'". compone ...

What are some creative ways to incorporate a variety of images into my website?

Currently working on a webpage and running into an issue. I have a div called "background" where I am loading several images using the <img>-tag. The problem is that the images are set to float:left;, causing them to wrap onto a new line as they can& ...

Looking to retrieve country, state, city, and area based on inputting a pincode value using Node.js?

I'm currently working on a web project with nodeJs and ejs. I am looking for a solution that can automatically update the country, state, city, and area fields based on the input of a pin-code (zip-code). Are there any recommended packages in node js ...

Vue - Additional loading may be required to manage the output of these loaders

Currently working with Vue and babel. I have a function that's been exported // Inside file a.js export async function get() { ... } I am trying to link this exported function to a static method of MyClass // Inside file b.js import myInterface fr ...

Tips for broadcasting the blob

I am currently working on a radio system project that involves streaming live audio from a microphone to the user in real-time. However, I am new to using node.js and unsure of how to achieve this. Can anyone provide guidance on how to stream the audio fro ...

Troubleshooting a problem with data retrieval in Hygraph and Next JS

I'm currently facing an issue while attempting to fetch data from Hygraph in a fresh Next JS application. The error message I'm encountering is: Error: Cannot read properties of undefined (reading 'map'). As a beginner in both technolo ...