json data in grouped bar chart - javascript

This is the url json data
[{"call_time":"0","total_inc_traffic":"1363.10","total_out_traffic":"88.70"},
{"call_time":"1","total_inc_traffic":"479.57","total_out_traffic":"36.98"},
{"call_time":"2","total_inc_traffic":"239.57","total_out_traffic":"13.43"},
{"call_time":"3","total_inc_traffic":"190.28","total_out_traffic":"8.20"},
{"call_time":"4","total_inc_traffic":"223.80","total_out_traffic":"0.00"},
{"call_time":"5","total_inc_traffic":"158.87","total_out_traffic":"19.58"},
{"call_time":"6","total_inc_traffic":"27.52","total_out_traffic":"36.18"},
{"call_time":"7","total_inc_traffic":"47.70","total_out_traffic":"69.57"},
{"call_time":"8","total_inc_traffic":"2234.35","total_out_traffic":"137.60"},
{"call_time":"9","total_inc_traffic":"150.67","total_out_traffic":"162.07"},
{"call_time":"10","total_inc_traffic":"4497.05","total_out_traffic":"267.32"},
{"call_time":"11","total_inc_traffic":"5049.87","total_out_traffic":"242.42"},
{"call_time":"12","total_inc_traffic":"5227.67","total_out_traffic":"286.88"},
{"call_time":"13","total_inc_traffic":"3384.30","total_out_traffic":"360.88"},
{"call_time":"14","total_inc_traffic":"3650.73","total_out_traffic":"328.28"}]
How to show this json data in a grouped bar graph. The bar graph can be any bar graph. Please help

Related

Chart JS Implementation of Gantt Chart

I would like to add dynamic data to a chart JS Horizontal Bar Graph,
How would I implement this on a data that is coming from mysql
data: [
['2022-01-01', '2022-01-15'], <<<<< this one how would I able to replace it with my own data
]
data

passing own data to trading view

I was working with trading view(https://www.tradingview.com/chart/?symbol=NASDAQ:AAPL&source=unauth_header&feature=launch_chart) charting library, It shows the data for the currency pair as intended.
I have looked into the following guideline
tradingview charting library
Now what I am looking for is to plot the chart with my own data. Is there any widget or any way I can provide my own data to tradingview and it will create the candlestick chart with the data provided.
yes you can feed your data with custom DataFeed.
you should set datafeed property of your widgetOptions like this
let options={
... other options
datafeed:new UDFCompatibleDatafeed('url api url'),
... other options
}
_chart = new widget(this.options);

Passing Morris Chart data by Viewmodel property with MVC

I am building a Morris Chart based on a database data and I pass to the View using the Viewmodel:
Razor code:
#Html.HiddenFor(m => m.SurveyLastDaysChartData)
HTML code:
<input id="SurveyLastDaysChartData" name="SurveyLastDaysChartData" type="hidden" value="[{"Date":"2016-07-18","Average":0},{"Date":"2016-07-17","Average":0},{"Date":"2016-07-16","Average":0},{"Date":"2016-07-15","Average":4.125},{"Date":"2016-07-14","Average":0},{"Date":"2016-07-13","Average":0},{"Date":"2016-07-12","Average":0}]">
The problem is that the Javascript side can't read the data because it's in string format.
var _surveyLastDaysChartId = "dsb-survey-last-days-chart";
var _surveyLastDaysChartData = $("#SurveyLastDaysChartData");
Morris.Line({
// ID of the element in which to draw the chart.
element: _surveyLastDaysChartId,
// Chart data records -- each entry in this array corresponds to a point on the chart.
data: _surveyLastDaysChartData.val(),
// The name of the data record attribute that contains x-values.
xkey: 'Date',
// A list of names of data record attributes that contain y-values.
ykeys: ['Average'],
// Labels for the ykeys -- will be displayed when you hover over the chart.
labels: ['Value']
});
I would like to keep the chart data in the Viewmodel and avoid Javascript in the View, how can I do that?
Thanks.
In your view, serialize the property and set to a javascript variable. This will be JSON.
<script>
var chartData = #Html.Raw(Newtonsoft.Json.JsonConvert
.SerializeObject(Model.SurveyLastDaysChartData));
</script>
Now you can use the chartData variable in your javascript code.
data : #(Html.Raw(System.Web.Helpers.Json.Encode(Model.ListOfYouNeed)))

Retrieve data from Parse.com and Display it in amcharts.js or highchart.js

How can I retrieve data from Parse.com through javascript or API and display it with amcharts.js or highcharts.js?
Or are there any other chart js I can try?
Thanks in advance.
amCharts wrote a tutorial how to load external data, if you receive an array of objects you can pass it directly to the chart instance to create it or call "validateData" to apply the data changes.
var chart = AmCharts.makeChart("chartdiv", { ... });
...
chart.dataProvider = newDataArray;
chart.validateData();

Highcharts wrapper similar to Google visualization chartwrapper

In Google visualization ChartWrapper class, the code to draw a chart (bar chart, pie chart, etc) is as follows:
wrapper = new google.visualization.ChartWrapper({
dataTable: dataTable.toJSON(),
chartType: chartType,
options: options
});
console.log("Wrapper: " + wrapper.toJSON());
console.log(" ");
wrapper.draw(result[0]);
I am curious if there's an equivalent way of doing this using Highcharts where instead of calling new google.visualization.chartWrapper(...), we can just call something like new highcharts.chartWrapper(...). The options can include the container div id where the chart will be drawn.
Even if there is no way to do, any suggestions how I should be go about doing something similar to this?
As far as I know, in dataTable I can specify my data series in JSON format. In chartType, I can specify bar, column, pie, etc. Based on the highcharts example I saw, I can even write a service that generates a HTML file on the server side as shown here -> http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/column-basic/ and send back a response.
But what I don't know is how do I tell Highcharts to insert the chart right at container id specified in my options on the same page.
In this example, for instance, wrapper is just a json representation of the chart (which I can generate). What I am not sure is how do I convert that json representation to a highcharts map that gets inserted where I want on the same page.
Sorry, if this question seems complicated. I can clarify if you need additional information.

Categories

Resources