Ingo

Setting horizontal lines on a chart

Recommended Posts

Hello,

I'm using FusionCharts to display candlestick charts like so:

image.thumb.png.0fd0188a31f48a3c5c41054753c3ec4e.png

I would like to draw to horizontal lines into the chart (one representing a stop-loss level, and the other one a target level).

I read about this here: https://www.fusioncharts.com/dev/chart-guide/chart-configurations/div-lines-and-grids and assume that this might point me in the right direction.

However, when I implement that into my JS code, the chart does not display any changes to the grid and does not show those minimum and maximum lines. What am I doing wrong?

Here is the code:

var fusionTable = new FusionCharts.DataStore().createDataTable(data, schema);

    chart = new FusionCharts({
      type: 'timeseries',
      renderAt: 'chart-container',
      width: "100%",
      height: 600,
      dataSource: {
        data: fusionTable,
        chart: {
          "theme": "fusion",
          "adjustDiv": "0",
          "yAxisMaxvalue": "0.7",
          "yAxisMinValue": "0.3",
          "numDivLines": "10",
          "divLineColor": "#6699cc",
          "divLineAlpha": "60",
          "divLineDashed": "0"
        },
        caption: {
          "text": "RatioChart"
        },
        yAxis: [{
          "plot": {
            "value": {
              "open": "Open",
              "high": "High",
              "low": "Low",
              "close": "Close"
            },
            "type": "candlestick"
          },
          "format": {
            "prefix": ""
          },
          "title": "Ratio long/short",
          "orientation": "right"
        }],
      }
    }).render();
 

Many thanks,

Ingo

Share this post


Link to post
Share on other sites

Hi Ingo,

In FusionCharts you can use the "Reference Line" feature to draw an arbitrary fixed line which can help you quickly compare any data point against the fixed value line. Hence, we suggest you to use reference lines to represent the Stop-Loss Level, and the Target Level as per your requirement.

Also, you can set the maximum and minimum limits of the Y-axis by using the "min" and "max" attributes under the "yAxis" object.

Please refer to this fiddle for the implementation: http://jsfiddle.net/7ozmhp0t/

In the above sample, the "referenceLine" objects array is defined under "yAxis" to configure the two target levels.

Documentation links:-
Reference Line: https://www.fusioncharts.com/dev/fusiontime/fusiontime-component/reference-line-in-fusiontime
Set Y-axis limits: https://www.fusioncharts.com/dev/fusiontime/fusiontime-component/y-axis-in-fusiontime#set-y-axis-limits

Hope this will help.

Thanks,

Srishti Jaiswal

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now