I have a problem with the VizFrame control of the SAPUI5 Framework. I want to display some data in an complex chart with two Y-axes. My data model looks like this:
{
"d" : {
"results" : [
{
"DataA" : "2",
"DataB" : "4",
"Id" : "1",
},
{
"DataA" : "3",
"DataB" : "2",
"Id" : "2",
}
]
}
}
I tried to display DataA on the left Y-Axis and DataB on the right one, while using the Id for the X-Axis. This works without problems with the VizFrame types: dual_line and dual_column.
I havent found a way to display the data as a bar (DataA on Y1) and line (DataB on Y2). My current coding looks like this:
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData("data.json");
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [{
axis : 2,
name : oLocText.getText('Id'),
value : "{Id}"
}],
measures : [{
group : 1,
name : DataA,
value : '{DataA}'
},{
group : 2,
name: DataB,
value: '{DataB}'
}],
data : {
path : "/d/results"
}
});
oVizFrame.setDataset(oDataset);
oVizFrame.setModel(oModel);
oVizFrame.setVizType('combination');
oVizFrame.setVizProperties({
title: {
visible: true,
text: "Combined"
},
plotArea: {
colorPalette : d3.scale.category20().range(),
}});
var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "primaryValues",
'type': "Measure",
'values': [ DataA , DataB]
}),
feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "axisLabels",
'type': "Dimension",
'values': [ Id]
});
oVizFrame.addFeed(feedValueAxis);
oVizFrame.addFeed(feedCategoryAxis);
Thank you very much for your help!
Please try:
var feedValueAxis1 = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "valueAxis",
'type': "Measure",
'values': [ DataA ]
}), feedValueAxis2 = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "valueAxis2",
'type': "Measure",
'values': [DataB]
}),
it will automatically plot DataA against left axis as bar and DataB against right axis as line.
Please be noticed that dual combination was available starting from SAPUI5 1.40.
I don´t know if your question is still relevant.
If I got your question right it´s about displaying measures as bar / line. I had a similar problem and I solved it by setting the dataShape property of plotArea:
oVizFrame.setVizProperties({
plotArea: { dataShape : {primaryAxis : ['bar','bar','bar'],
secondaryAxis : ['line', 'line', 'line']}}
});
In this example a maximum of 3 measures on each axis would be drawn as bar on axis 1 and as line on axis 2. I guess once you see this coding you know what to do when you would like to change bar vs. line.
One remark: only 'bar' and 'line' are allowed here (I checked the docu and also source code).
Best regards,
Sebastian
Related
I know you can pass arbitrary data into your time series points, such as:
new Highcharts.Chart( {
...,
series: [{
name: 'Foo',
data: [ { y : 10.0, customData : 'value 1' },
{ y : 20.0, customData : 'value 2' },
{ y : 30.0, customData : 'value 3' } ]
}]
} );
However, I noticed that this doesn't quite work in HighStock when your time series is comprised of a large data set (1000+ points).
For example, here is a working fiddle http://jsfiddle.net/gparajon/c5fej775/ (less than 1000 points, which also happens to be the default turboThreshold). And here's the same fiddle, with more data, which breaks the tooltip formatter: http://jsfiddle.net/gparajon/5om258az/
Any workaround?
Thanks!
The error in the console is a bug and it is not really connect why you cannot access extra info in the formatter.
The difference between a chart and a stockchart is that a stockchart does data grouping, what means that in the formatter callback you receive grouped points which does not include extra data (how should they be grouped?).
example: https://jsfiddle.net/g04La2qh/1/
If you disable data grouping, you will receive non-grouped points with extra data.
dataGrouping: {
enabled: false
},
example: https://jsfiddle.net/g04La2qh/2/
i have json data in following format.
{
"2" : {
"question" : "How did you like our Food?",
"avg_rating" : {
"2016-05-23" : 3.7142857142857,
"2016-05-25" : 4.5
}
},
"3" : {
"question" : "How did you like our drinks?",
"avg_rating" : {
"2016-05-23" : 3.4285714285714,
"2016-05-25" : 4
}
}
}
i want it to be formatted in following format where above data should be inside data variable of plot object.
var plot = [{
label: "",
data: [
[2016-05-23, 3.7142857142857],[2016-05-25, 4.5]
],
points: {fillColor: '#006699'}
},{
label: "",
data: [
[2016-05-23, 3.4285714285714],[2016-05-25, 4]
],
points: {fillColor: '#009933'}
}];
i am not good in english so i may not have been able to explain this problem properly. please help me to sort out this problem.
I am using jqPlot in phonegap but some problem is there like if I gave static value to pie chart then it works well but if I gave dynamic value then not rendering correctly
Static chart :-
$.jqplot('chartdiv', [ [ [ 'Cricket', 42],
[ 'Football', 8 ],
[ 'Basketball', 4 ], [ 'Chess', 28 ],
[ ' TableTennis', 18 ] ] ], {
seriesDefaults : {
renderer : $.jqplot.PieRenderer,
rendererOptions : {
showDataLabels : true
}
},
legend : {
show : true,
location : 'e'
}
});
O/P :-
Dynamic chart :-
var cricketPortion = document.getElementById("value_1").value;
var footballPortion = document.getElementById("value_2").value;
var basketballPortion = document.getElementById("value_3").value;
var chessPortion = document.getElementById("value_4").value;
var ttPortion = document.getElementById("value_5").value;
$.jqplot('chartdiv', [ [ [ 'Cricket', cricketPortion ],
[ 'Football', footballPortion ],
[ 'Basketball', basketballPortion ], [ 'Chess', chessPortion ],
[ ' TableTennis', ttPortion ] ] ], {
seriesDefaults : {
renderer : $.jqplot.PieRenderer,
rendererOptions : {
showDataLabels : true
}
},
legend : {
show : true,
location : 'e'
}
});
O/P :-
Tell me how can I get rid of this..??
Try with this you will get result
Use parseInt for every value
parseInt(document.getElementById("value_1").value)
DEMO
Use the parseInt function of Javascript to parse the String values into Integers Eg: parseInt(document.getElementById("value_1").value)
jqPlot excepts an value(integer) to plot the sections/divisions on the canvas(be it a pie-chart, bar-chart or any other chart)
So its [ label(a String), value(an Integer) ]
Make sure the data-type of the second field is of Integer type
Hope it helps.
I am trying to implement a stacked bar graph and I would like to understand if there is anyway that we can specify the category along with the data point in series.
I have Categories as :
xAxis: {
categories: ['DEV', 'TEST', 'Stage']
},
Series data:
series: [{
name: 'Severity-1',
data: [['TEST',20]]
},{
name: 'Severity-2',
data: [['TEST',20]]
}]
In above snippet I am trying to add a point value '30' to 'TEST' category but when I load the graph it shows up under 'DEV' category.
Example: http://jsfiddle.net/G5S9L/1/
Any idea?
Did you try:
{"xAxis": { "type" : "category" .... } ... }
It should get category from your data.
You need to use category index instead of category name, so proper example will be:
series: [{
name: 'Severity-1',
data: [[1,20]] //0-DEV, 1-TEST, 2-Stage
},{
name: 'Severity-2',
data: [[1,20]]
}]
Hey Vipul Do you want something like this ? Please check the link below for the code.
series: [{
name: 'Severity-1',
data: [['TEST',20]]
},{
name: 'Severity-2',
data: [['TEST',20]]
}]
CHECK EXAMPLE
I create a Column chart using Kendo ui dataviz.
In my program, i am going to bind the local Javascript Array variable data to chart datasource.
The JSON data was spilted like "3""9""6" for "396".
I dont know why it happened. My Source code is given blow. Please check it and Please give the solution.
Source:
/**************Variable Declaration**********************************/
var eligibilityData = new Array();
eligibilityData = {
mem_status: {
a: 396, b: "56", c: "1125", d: "8423"
}
};
/**************Create Chart**********************************/
function createBarChart(eligibilityData) {
/****** Issue: A value is 396 but it spilted into "3","9","6"************/
$("#Chart1").kendoChart({
theme : $(document).data("kendoSkin") || "default",
dataSource : {
data: JSON.stringify(eligibilityData.mem_status.a),
},
seriesDefaults: { type: "column", },
series : [
{ field: "a", name : "A" }
],
tooltip : { visible: true, },
});
}
Local data should be passed as an array. No need to call JSON.stringify
data: [eligibilityData.mem_status]
See: http://docs.kendoui.com/api/framework/datasource#configuration-data-Array
JSON.stringify does not do what you expect. What you sentence really does is:
It gets the number 396 and converts it to a string.
Converts a string into an array of one character per element.
Not sure about the way you define the DataSource (why you want a DataSource with only one element) but if that is really what you want, you might try:
dataSource : {
data: [eligibilityData.mem_status.a]
},
or
dataSource : {
data: [eligibilityData.mem_status]
},