How to set certain columns to Bubble Chart dataLabel in highcharts (Rcharts)? - highcharts

How to set "prd_nm" column to bubble chart's data label?
I try to use "plot Options : format" option, but i can't find it.
data <- top30
colnames(data) <- c('prd_rk', 'prd_nm', 'category', 'strategy', 'plc',
'sales', 'purchases', 'customers', 'age', 'purchase_rate',
'repurchase_rate')
hc <- hPlot(sales ~ purchases, data = data, type = "bubble", size =
"customers", group = "strategy")
hc$plotOptions(series=list(dataLabels=list(enabled=TRUE, formmat= .
{"y"})))
hc$set(height = 500)
hc$colors(palette)
hc

You have a little typo there with formmat. Please try to change your code to:
hc$plotOptions(series=list(dataLabels=list(enabled=TRUE, format="{prd_nm}")))

Related

Trying to use add = True and I get an error message

I am Trying to use add = True and I get an error message. How can I do it?
This is my code
quadratcount(schools.pp)
plot(schools.sp, col = "red")
plot(quadratcount(schools.pp), add= T)`
and this is the error message I get
Error in (function (x, y = NULL, density = NULL, angle = 45, border = NULL, : plot.new has not been called yet
Looks like you made a simple typo: In the first plot command you write plot(schools.sp, col = "red"), where you probably meant plot(schools.pp, col = "red"). For future questions please provide a reproducible example where we can run each line including library(spatstat) and the definition of schools.pp etc. If you can't share your data just either:
use the first few points of your data
use a built-in dataset
generate artificial data

How to generate custom tooltips in XPlot.GoogleCharts Treemap (F#)?

I want to generate a tooltip as described on the Google site (https://developers.google.com/chart/interactive/docs/gallery/treemap#tooltips),
and i cannot figure out how.
I took the example from https://fslab.org/XPlot/chart/google-treemap-chart.html and want to modify it, so that i have custom tooltips:
let tt =
Tooltip (
//...
)
let options =
Options(
title = "Treemap",
minColor= "#009688",
midColor= "#f7f7f7",
maxColor= "#ee8100",
headerHeight = 50,
headerColor = "#9ebcda",
fontColor = "black",
tooltip = tt,
showTooltips = true,
showScale = true
)
data
|> Chart.Treemap
|> Chart.WithOptions options
|> Chart.WithLabels
[
"Location"
"Parent"
"Market trade volume (size)"
"Market increase/decrease (color)"
]
|> Chart.Show

Type of data received from SQLAlchemy database to plot chart

I am trying to plot a graph using highcharts in Flask. I have no problems when I give the data in the code itself. But when I retrieve the data from the database, it returns with a , in the end like
[(72,),(70.5,),(78.8,),(73,),(76,),(75,),]
So, this is not passing the data to the graph and I have an empty space on the webpage.
This is the code I have used:
views.py
#control.route("/")
def index(chartID = 'chart_ID', chart_type = 'line', chart_height = 350):
chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,}
series = [{"data": [tempg()]}]
title = {"text": 'My Title'}
xAxis = {"title": {"text": 'xAxis Label'}}
yAxis = {"title": {"text": 'yAxis Label'}}
return render_template('control/index.html', uptime=GetUptime(), chartID=chartID, chart=chart, series=series, title=title, xAxis=xAxis, yAxis=yAxis)
def tempg():
tempgrs = [tempg for tempg in Temperature.query.with_entities(Temperature.tempft).all()]
return tempgrs
Is it because of the extra comma at the end, that i'm not able to get the chart or is it any other coding fault.
Thanks in Advance.

Highcharts bar chart with varied bar widths?

I want to make stacked bar chart where each portion has a width that encodes one value (say "Change" in the data below) and a height that encodes another value ("Share")
In some ways this is like a histogram with different bin sizes. There are a few "histogram" questions but none seem to address this. Plot Histograms in Highcharts
So given data like this:
Category Share Price Change
Apples 14.35 0.1314192423
Horseradish 46.168 0.1761474117
Figs 2.871 0.018874249
Tomatoes 13.954 0.0106121298
Mangoes 7.264 0.1217297011
Raisins 5.738 0.0206787136
Eggplant 6.31 0.0110160732
Other produce 3.344 0.0945377722
I can make a stacked bar that captures the "share" column in widths:
And another that captures the "change" column in heights:
And I can use an image editor to combine those into this histogram-like beast:
Which really captures that horseradish is a huge deal. So my question is, can I do that within Highcharts?
You can realise that by using snippet.
(function (H) {
var seriesTypes = H.seriesTypes,
each = H.each,
extendClass = H.extendClass,
defaultPlotOptions = H.getOptions().plotOptions,
merge = H.merge;
defaultPlotOptions.marimekko = merge(defaultPlotOptions.column, {
pointPadding: 0,
groupPadding: 0
});
seriesTypes.marimekko = extendClass(seriesTypes.column, {
type: 'marimekko',
pointArrayMap: ['y', 'z'],
parallelArrays: ['x', 'y', 'z'],
processData: function () {
var series = this;
this.totalZ = 0;
this.relZ = [];
seriesTypes.column.prototype.processData.call(this);
each(this.zData, function (z, i) {
series.relZ[i] = series.totalZ;
series.totalZ += z;
});
},
translate: function () {
var series = this,
totalZ = series.totalZ,
xAxis = series.xAxis;
seriesTypes.column.prototype.translate.call(this);
// Distort the points to reflect z dimension
each(this.points, function (point, i) {
var shapeArgs = point.shapeArgs,
relZ = series.relZ[i];
shapeArgs.x *= (relZ / totalZ) / (shapeArgs.x / xAxis.len);
shapeArgs.width *= (point.z / totalZ) / (series.pointRange / series.xAxis.max);
});
}
});
}(Highcharts));
Example: http://jsfiddle.net/highcharts/75oucp3b/

highcharts JoeKuan set title

i m using highcharts JoeKuan, but i have tried set title, all failed.
JoeKuan HighCharts : https://github.com/JoeKuan/Highcharts_Sencha/
a lot of example i have tried, maybe JoeKuan's High Chart set title is bug?
this is the example i have tried: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/members/chart-settitle/
chart.setTitle({
text: 'New title ' + i++
});
Error : TypeError: chart.setTitle is not a function
or
chart.options.subtitle.text = 'Sales';
or
chart.title = "a"
any idea?

Resources