Kiluminati
Kiluminati

Reputation: 73

Chart.js place y value position and its x-label position relative to the x-value

Is it possible for me to supply a chart.js chart with a list of Y values that have a corresponding label/X value and place them vertically and horizontally relative to their own value.

For example: I have a list of values at a certain time (unix timestamp) that I want to show on a chart, with its Y value positioned relative, but also its horizontal position and its label relative on the x-scale.

The Y values and its labels are both automatically positioned according to their values

At this moment it always spaces out my labels, completely over the entire x axis, at equal distances, without taking into account the values of the labels itself. Is there way to automatically accomplish this with chart.js ?

Upvotes: 0

Views: 1180

Answers (1)

mMerlin
mMerlin

Reputation: 109

A line or scatter chart will do the job. The main criteria is that the data is a series of x and y coordinates. Each point in the array is in the form:

{
  x: xValue,
  y: yValue
}

See http://www.chartjs.org/samples/latest/charts/scatter/basic.html

here is a jsfiddle that reproduces your image.

Upvotes: 1

Related Questions