I'm currently using Google Visualisation library to (Google Charts) to visualize some of my data. I'm plotting a stacked bar graph with cumulative data, but I'd like to print an additional bar / line that shows the increase per day, rather than the total per day. I have read about Combo Charts but I can't seem to find a way to combine a stacked bar chart with a line chart.
Is this possible at all?
it's possible, is there more you can share? specifically a sample of the data?
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Diff'],
['2004/05', 165, 938, 522, 998, 450, 614.6],
['2005/06', 135, 1120, 599, 1268, 288, 682],
['2006/07', 157, 1167, 587, 807, 397, 623],
['2007/08', 139, 1110, 615, 968, 215, 609.4],
['2008/09', 136, 691, 629, 1026, 366, 569.6]
]);
var options = {
title : 'Monthly Coffee Production by Country',
vAxis: {title: 'Cups'},
hAxis: {title: 'Month'},
seriesType: 'bars',
isStacked: true,
series: {5: {type: 'line'}}
};
var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
chart.draw(data, options);
}
<script src="https://www.google.com/jsapi"></script>
<div id="barchart_values" style="width: 900px; height: 300px;"></div>
Related
I have encountered a couple of issues when using supersetEmbeddedSdk (apache-superset==2.0.0):
I cannot hide filters with
filters: {
expanded: false,
visible: false,
}
in the network communication I can see that there is a call to http://localhost:8088/api/v1/dashboard/2/filter_state?tab_id=1 which results in 500 error {msg: "Missing Authorization Header"}
in the logs I can see
2022-10-04 18:24:22,760:ERROR:root:'GuestUser' object has no attribute 'get_user_id'
Traceback (most recent call last):
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 86, in wraps
return f(self, *args, **kwargs)
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/utils/log.py", line 245, in wrapper
value = f(*args, **kwargs)
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/dashboards/filter_state/api.py", line 98, in post
return super().post(pk)
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/views/base_api.py", line 83, in wraps
return f(self, *args, **kwargs)
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/temporary_cache/api.py", line 76, in post
key = self.get_create_command()(args).run()
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/temporary_cache/commands/create.py", line 35, in run
return self.create(self._cmd_params)
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/dashboards/filter_state/commands/create.py", line 41, in create
entry: Entry = {"owner": get_owner(actor), "value": value}
File "/Users/sebastiankruk/Development/private/paiku/.envs/lib/python3.9/site-packages/superset/key_value/utils.py", line 70, in get_owner
return user.get_user_id() if not user.is_anonymous else None
AttributeError: 'GuestUser' object has no attribute 'get_user_id'
However the chart renders correctly and I was even able to expand the iframe with the following code (my app is written in Flask):
supersetEmbeddedSdk.embedDashboard({
id: '{{ dashboard_id }}',
supersetDomain: '{{ superset_public_url }}',
mountPoint: document.getElementById('{{ chart_wrapper }}'),
fetchGuestToken: () => '{{ token }}',
dashboardUiConfig: {
hideTitle: true,
hideTab: true,
hideChartControls: true,
filters: {
expanded: false,
visible: false,
}
}
}).then(embedVSC => {
const size = embedVSC.getScrollSize();
if (size.width !== 0) {
const iframe = document.querySelector("#{{ chart_wrapper }} > iframe");
iframe.setAttribute("width", "100%");
iframe.setAttribute("height", "450");
}
})
and last but certainly not least … each time I enter a page with the chart my session is being terminated and I have to re-login to my app
I tried to skip the filters section but the same call was being made with the same result (500).
What am I missing?
I am trying to create a stacked Google Chart. It's easy, but with the current data set I have i'm a bit confused. I need a stacked chart, but with some of the bars I don't need all columns. Some, I only need 2, 3 or sometimes just 1 column of data. For example, suppose I have:
data.addColumn('string', 'Topping');
data.addColumn('number', 'Nescafe Instant');
data.addColumn('number', 'Folgers Instant');
data.addColumn('number', 'Nescafe Beans');
data.addColumn('number', 'Folgers Beans');
data.addRows([
['2001', 321, 621, 816, 319],
['2002', 163, 231, 539, 594],
['2003', 125, 819, 123, 578],
['2004', 197, 536, 613, 298]
]);
I need this:
data.addColumn('string', 'Topping');
data.addColumn('number', 'Nescafe Instant');
data.addColumn('number', 'Folgers Instant');
data.addColumn('number', 'Nescafe Beans');
data.addColumn('number', 'Folgers Beans');
data.addRows([
['2001', 321, 621, 816, 319],
['2002', 163, 231, 539, 594],
['2003', 578],
['2004', 197, 536]
]);
With this current format, it does not work. Not only that, the third row (578) should refer to Folgers Beans and not Nescafe Instant. How can I fix these problems so that the graph displays and it also displays with the correct information?
I have figured out the answer. In order to solve this problem, you have to add undefined to the empty fields. For example:
data.addColumn('string', 'Topping');
data.addColumn('number', 'Nescafe Instant');
data.addColumn('number', 'Folgers Instant');
data.addColumn('number', 'Nescafe Beans');
data.addColumn('number', 'Folgers Beans');
data.addRows([
['2001', 321, 621, 816, 319],
['2002', 163, 231, 539, 594],
['2003', undefined, undefined, undefined, 578],
['2004', undefined, undefined, 197, 536]
]);
I trying to connect a php client (using php-amqplib lib) to a server based on wso2mb (wso2 message broker version 3.1.0).
I couldnt succed in that when using the amqp_consumer.php and always locked with this error :
INFO {org.wso2.andes.server.protocol.AMQProtocolEngine} - Unable to create SASL Server:AMQPLAIN whilst processing:[ConnectionStartOkBodyImpl: clientProperties={product=[LONG_STRING: AMQPLib], platform=[LONG_STRING: PHP], version=[LONG_STRING: 2.6], information=[LONG_STRING: ], copyright=[LONG_STRING: ], capabilities=[FIELD_TABLE: {authentication_failure_close=[BOOLEAN: true], publisher_confirms=[BOOLEAN: true], consumer_cancel_notify=[BOOLEAN: true], exchange_exchange_bindings=[BOOLEAN: true], basic.nack=[BOOLEAN: true], connection.blocked=[BOOLEAN: true]}]}, mechanism=AMQPLAIN, response=[5, 76, 79, 71, 73, 78, 83, 0, 0, 0, 5, 97, 100, 109, 105, 110, 8, 80, 65, 83, 83, 87, 79, 82, 68, 83, 0, 0, 0, 5, 97, 100, 109, 105, 110], locale=en_US]
[2016-11-04 08:05:26,901] INFO {org.wso2.andes.server.protocol.AMQProtocolEngine} - Closing connection due to: org.wso2.andes.AMQConnectionException: Unable to create SASL Server:AMQPLAIN [error code 506: resource error]
I using thos params in confing.php as conexions params
require_once __DIR__ . '/../vendor/autoload.php';
define('HOST', 'localhost');
define('PORT', 5692);
define('USER', 'admin');
define('PASS', 'admin');
define('VHOST', '/');
My questions :
1. Could you recommand any php library / tutorial to establish communication between some php code and wso2mb ?
2. What are the connexion method that are allowed by wso2mb ? (PLAIN, AMQPLAIN...?)
3. Help plz :)
I have a list of lists and I want to convert to list of frozenset in original order. I've tried the code below but the output isn't in the original order.
data=[[118, 175, 181, 348, 353], [117, 175, 181, 371, 282, 297], [119, 166, 176, 54, 349]]
my code:
>>> transactionList=list()
>>> for rec in data:
transaction = frozenset(rec)
transactionList.append(transaction)
output i got is not in original order:
>>> transactionList
[frozenset([353, 348, 181, 118, 175]), frozenset([297, 175, 371, 181, 282, 117]), frozenset([176, 349, 54, 166, 119])]
my expected output in original order:
>>> transactionList
[frozenset([118, 175, 181, 348, 353]), frozenset([117, 175, 181, 371, 282, 297]),frozenset([119, 166, 176, 54, 349])]
frozensets, like sets, have no defined order. See Does Python have an ordered set? for ways to overcome this with custom classes.
I'm not sure if this is an issue because charts are currently being updated in Bokeh but I can no longer plot a complete dataframe using Line charts from Bokeh in my Jupyter notebook. Using this example from the docs:
from collections import OrderedDict
import numpy as np
import pandas as pd
from bokeh.charts import Line
from bokeh.plotting import show, output_file
from bokeh.charts import Chart, Line
xyvalues = OrderedDict(
python=[2, 3, 7, 5, 26, 221, 44, 233, 254, 265, 266, 267, 120, 111],
pypy=[12, 33, 47, 15, 126, 121, 144, 233, 254, 225, 226, 267, 110, 130],
jython=[22, 43, 10, 25, 26, 101, 114, 203, 194, 215, 201, 227, 139, 160],
)
# any of the following commented are valid Line inputs
xyvalues = pd.DataFrame(xyvalues)
#xyvalues = xyvalues.values()
#xyvalues = np.array(xyvalues.values())
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, title="Lines", ylabel='measures', legend=True)
show(chart)
I get: Incorrect dataframe plot which is clearly different to the example shown in the docs.
If I explicitly give the dataframe an index and pass all the columns like below then it gives the expected plot:
xyvalues = pd.DataFrame(xyvalues, index=range(14))
output_file("lines.html", title="line.py example")
chart = Line(xyvalues, y=['python', 'pypy', 'jython'],
title="Lines", ylabel='measures', legend=True)
show(chart)
My notebook specs:
You are using Jupyter notebook.
The version of the notebook server is 4.0.6 and is running on:
Python 2.7.11 |Anaconda 2.4.1 (64-bit)| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython 4.0.1 -- An enhanced Interactive Python.
Updating to 0.11.0dev4 through conda fixed the issue.
conda install -c bokeh/channel/dev bokeh