I'm facing a problem loading a simple external file with just one value into my jqplot meter gauge.
Here is my working fiddle with hardcoded data: https://jsfiddle.net/enqjh8m3/1/
I read through the jqplot documentation and looked at some examples but I just can't make it work. It's the first time I use jqplot and I'm not very experienced working with js. But havent we all started somewhere?
Here is my approach to load a file called keyscore.txt, which just contains
[66]
My not working code:
<script type="text/javascript"> var ajaxJqPlot = { settings : { data_url : "keyscore.txt", element_id : "chart0" }, plot : function(settings){ t = this; $.extend(t.settings, settings); $.ajax({ async : false, url : t.settings.data_url, dataType :"json", success : t.renderer }); }, renderer : function(res){ t = this; $.jqplot('chart0', res.data, { seriesDefaults: { renderer: $.jqplot.MeterGaugeRenderer, rendererOptions: { label: 'Keyword Health Score', labelPosition: 'bottom', min: 0, max: 100, intervals:[30, 60, 80, 100], intervalColors:['#cc6666', '#E7E658', '#93b75f', '#66cc66'], // ringColor: '#363636', // tickColor: '#363636', ringWidth: 0.5, padding: 30, background :"#ededed", ticks: [0, 15,50,75,100], intervalInnerRadius: 50, intervalOuterRadius: 120, hubRadius: 10, // needleThickness: 5, ); } }; $(document).ready(function(){ ajaxJqPlot.plot(); });
A copy of keyscore.txt can be found here
Maybe someone can help me out and look at my code or point me into the right direction? Any help is very appreciated!