chartjs / chartjs-chart-financial

Chart.js module for charting financial securities
MIT License
743 stars 199 forks source link

Using chartjs-chart-financial with x-Axis not as a time axis #41

Closed psyogi closed 6 years ago

psyogi commented 6 years ago

Is it possible to use non-time related data on the x-axis?

benmccann commented 6 years ago

What would you like to see instead? Do you have an example from another site that you can share?

psyogi commented 6 years ago

just a string label, same as a bar chart, but instead of a single value represented by a bar, I would like to use a candlestick with 4 values for every x-axis label. For example say I have 10 bicyclists cycling a 10 km distance many times everyday and recording the time. So I have this data for a month. I want to plot a candlestick graph with the names of the cyclists on the x axis, and the candle corresponding to their name representing their best time, worst time, daily average time at the start of the month and daily average time at the end of the month.

benmccann commented 6 years ago

It might work if you pass the data as { x, o, h, l, c } instead of { t, o, h, l, c } and then set a category axis: https://www.chartjs.org/docs/latest/axes/cartesian/category.html

psyogi commented 6 years ago

Tried, but it doesnt work. The candlesticks are not rendered with the right spacing when the time Axis is not defined. Even when I pass the values as x: , it still takes it as a time param. So actually it is not possible to pass a string value as the x: attribute. If I define category axis and assign labels, the same weird spacing happens

benmccann commented 6 years ago

Hmm, that's too bad. I expected it should work or at least be close to it. This is really targeted towards financial charts, so I don't think we'll fix it ourselves. That being said if you want to send a fix, we'll consider it