My SVG Line chart isn't being displayed

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Skies on 25th October 2017
I get my data via PHP and display it with the code below

line_eq1_inter1 = new RGraph.SVG.Line({
             id: 'eq1_inter1',
             data: RGraph.SVG.arrayFill({
                 array: [],
                 value: 0,
                 length: 300
             options: {
                 labelAbove: true,
                 yaxisDecimals: 1,
                 hmargin: 0,
                 title: ' TEMP IN',
                 gutterLeft: 50,
                 gutterBottom: 50,
                 yaxisMax: 25,
                 yaxisMin: 0,
                 yaxisLabelsCount: 2,
                 xaxisLabels: ['5min', '4min', '3min', '2min', '1min'],
                 xaxisLabelsPosition: 'section',
                 xaxisTickmarks: false,
                 backgroundGridVlinesCount: 10,
                 xaxisColor: '#aaa',
                 yaxis: false,
                 backgroundGridColor: '#eee',
                 backgroundGridVlines: false,
                 backgroundGridBorder: false,
                 backgroundGridHlinesCount: 3,
                 filled: true,
                 colors: ['#c00'],
                 linewidth: 1,
                 filledColors: ['rgba(255,0,0,0.25)']

but when i try to display the value it doesn't display anything. Any help?
Posted by Richard on 25th October 2017
Hi there,

You're filling your array with a value of 0. Not sure why It's not showing a line - that's
probably a bug.

But you can just change the value to 0.00001 instead, like this:

data: RGraph.SVG.arrayFill({
     array: [],
     value: 0.00001,
     length: 300

Posted by Skies on 25th October 2017
The line shows alright with the values (i get my values from SQL Server with PHP) what i cant show is the "number value" on top of the line.
Posted by Richard on 25th October 2017
Hi there,
I see. Well instead of this:

labelAbove: true,

You should put this:

labelsAbove: true,

(add the 's'). But unless your chart is really wide the labels are going to be on top of each other.

Posted by Skies on 25th October 2017
well the your first answer helped me too because with just adding the 's' to "labelAbove" my chart would break...but with the value: 0.00001, it started to work again...the reason i can think its that he wanted to show the label but it only got null values at start.

Only one more question can't i just show the last value i'm adding to the chart? since showing all gonna do what you said, they are on top of each other.
Posted by Richard on 25th October 2017
Hi there,

To do that it's probably best to use the RGraph text function like this (assume that 'line' is your chart object variable):

var x = line.coords[line.coords.length - 1][0];
var y = line.coords[line.coords.length - 1][1] - 20;

     object: line,
     parent: line.svg.all,
     text: 'Bobby is the\r\nwinner!',
     halign: 'center',
     x: x,
     y: y,
     background: 'rgba(0,0,0,0.15)',
     padding: 5

Posted by Richard on 7th November 2017
Hi there,

The original problem with the arrayFill() function is now fixed. The problem was that it was filling the array with null values instead of zeros.


Add a reply

« Back to message list