HumbleSoftware / Flotr2

Graphs and Charts for Canvas in JavaScript.
http://www.humblesoftware.com/flotr2/
MIT License
2.45k stars 528 forks source link

Glitch in Candlestick barcharts:true #214

Open pmuston opened 11 years ago

pmuston commented 11 years ago

When using the candlesticks, when barcharts:true open and close not getting yscale correct.

An example : http://jsfiddle.net/ruba7/

Simple to fix by just apply your yScaling call on the open and close.

   if (options.barcharts) {
      context.moveTo(x, Math.floor(top + width));
      context.lineTo(x, Math.floor(bottom + width));
      y = Math.floor(yScale(open) + width) + 0.5; //  yScale applied here
      context.moveTo(Math.floor(left) + pixelOffset, y);
      context.lineTo(x, y);
      y = Math.floor(yScale(close) + width) + 0.5; // yScale applied here
      context.moveTo(Math.floor(right) + pixelOffset, y);
      context.lineTo(x, y);
    }
cesutherland commented 11 years ago

Thanks. I have never actually looked at the barcharts option, and chandlesticks needs some work in general.

I assume barcharts is just standard OHLC correct?

On Thu, Apr 11, 2013 at 9:48 AM, Paul Muston notifications@github.comwrote:

When using the candlesticks, when barcharts:true open and close not getting yscale correct.

An example : http://jsfiddle.net/ruba7/

Simple to fix by just apply your yScaling call on the open and close.

if (options.barcharts) { context.moveTo(x, Math.floor(top + width)); context.lineTo(x, Math.floor(bottom + width)); y = Math.floor(yScale(open) + width) + 0.5; // yScale applied here context.moveTo(Math.floor(left) + pixelOffset, y); context.lineTo(x, y); y = Math.floor(yScale(close) + width) + 0.5; // yScale applied here context.moveTo(Math.floor(right) + pixelOffset, y); context.lineTo(x, y); }

— Reply to this email directly or view it on GitHubhttps://github.com/HumbleSoftware/Flotr2/issues/214 .

pmuston commented 11 years ago

yes

I would be interested in contributing a separate OHLC chart to add more options. The OHLC is only useful for daily data where there is an overnight discontinuity. For other data 5 minute data and other non-financial data like mine, a HLC is required.

On 11 April 2013 15:00, Carl Sutherland notifications@github.com wrote:

Thanks. I have never actually looked at the barcharts option, and chandlesticks needs some work in general.

I assume barcharts is just standard OHLC correct?

On Thu, Apr 11, 2013 at 9:48 AM, Paul Muston notifications@github.comwrote:

When using the candlesticks, when barcharts:true open and close not getting yscale correct.

An example : http://jsfiddle.net/ruba7/

Simple to fix by just apply your yScaling call on the open and close.

if (options.barcharts) { context.moveTo(x, Math.floor(top + width)); context.lineTo(x, Math.floor(bottom + width)); y = Math.floor(yScale(open) + width) + 0.5; // yScale applied here context.moveTo(Math.floor(left) + pixelOffset, y); context.lineTo(x, y); y = Math.floor(yScale(close) + width) + 0.5; // yScale applied here context.moveTo(Math.floor(right) + pixelOffset, y); context.lineTo(x, y); }

— Reply to this email directly or view it on GitHub< https://github.com/HumbleSoftware/Flotr2/issues/214> .

— Reply to this email directly or view it on GitHubhttps://github.com/HumbleSoftware/Flotr2/issues/214#issuecomment-16235995 .