question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Adding new datasets at offset from origin in original chart

See original GitHub issue

Hi, I’m new to using Chart.JS and I’m a total noob in JS (but trying to learn) so please bear with me if this is somehow inappropriate.

For complete description of the rationale to this request please see this Q at stackoverflow.

I was trying to add some statistical projections (new datasets, both bar and lines) to the end of current datasets (combined bar/lines) but ran into some issues. I believe some of them can be fixed quickly and could make a good new feature.

First is the adding of multiple values to either labels or an existing dataset. I solved that as shown below, and I believe this could be implemented in a similar way by allowing [value1, value2,...,value_n] in the push() with evaluating if there are multiple values. Not very happy with repeating update() for every step though.

var futureValues = [55618.9002849,55762.088929589,55905.277574278];
var futureLabels = [2017,2018,2019];

function addData() {
    var index, count;
    for (index = 0, count = futureLabels.length; index < count; ++index) {
       myChart.data.labels.push(futureLabels[index]);
       myChart.data.datasets[1].data.push(futureValues[index]);
    }
    myChart.update();
}

Second is the general issue of not being able to specify a “starting point” for datasets when plotting multiple sets with different origins. I don’t know if maybe there is a way but then it should be added to the documentation.

Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jcopperfieldcommented, Nov 23, 2017

You don’t need to call myChart.update() inside the for-loop. Just add all the values and update once. The update function tells Chartjs you’re done modifying things and you want to the graphical result.

Adding min/maxvalues to your configuration might help to modify the start/end points of your x-axes (http://www.chartjs.org/docs/latest/axes/cartesian/time.html?h=min).

If the vertical scaling is a problem, you could add multiple y-axes for the several datasets.

0reactions
etimbergcommented, Oct 16, 2020

I think based on the conversation here, this is resolved and no further actions are needed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Offsetting seperate data sets within inset graph - OriginLab
I'm trying to add a new inset graph, and I want to then offset the graphs within that inset graph. However I cant...
Read more >
Problem: Datasets do not line up when added to ArcMap
After adding several datasets to an ArcMap Data Frame, features in some layers do not align correctly with other layers.
Read more >
User Guide 2022b - OriginLab
The purpose of this guide is to try and present a broad overview of Origin's capabilities. We hope that new users will find...
Read more >
API Reference — DataRobot Python Client 2.24.0 ...
Create new batch prediction job, upload the scoring dataset and return a batch ... first five new_flist = dataset.create_featurelist('Simple Features', ...
Read more >
Chapter 7: HDF5 Dataspaces and Partial I/O
The HDF5 dataspace is a required component of an HDF5 dataset or attribute ... The offset defines the origin of the hyperslab in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found