hAxis.title and vAxis.title options don't seem to set the axis titles for gvisScatterChart in the package googleVis.
plot(gvisScatterChart(data.frame(x = 3, y = 4), options=list(hAxis.title = 'foo')))
"foo" doesn't appear as the horizontal axis title.
You're supposed to pass options to hAxis in a dictionary-looking JSON object format:
plot(gvisScatterChart(data.frame(x = 3, y = 4), options=list(hAxis="{title:'foo'}")))
See the examples at the bottom of the help page and this under hAxis:
a JSON object. Default null. An object with members to configure various horizontal axis elements. To specify properties of this object, you can use object literal notation, as shown here:
{title: 'Hello', titleTextStyle: {color: '#FF0000'}}
Related
I am adding data to scatter series like below , how do we receive the custom parameter value I add here
series.add({
x: 0,
y: 22,
color: ColorRGBA(255, 0, 0),
size: 10,
rotation: 45,
value: "custom message",
});
From the above series how do I extract the value "custom message" .. basically is there anyway to get it ? so I can to use it in table formatter like below .
series.setCursorResultTableFormatter((builder, series, xValue, yValue,value) => {
return builder.addRow(value).addRow(series.getValue());
});
Also another doubt is can we change shape of series dynamically like we change color and size ?
With v.3.1 this kind of logic is not supplied out of the box.
To implement it you'd need to add some kind of custom logic which finds your custom data based on the X and Y information.
In next release, v.3.2 we'll add an extra parameter to cursor result table formatters, so you can use it like follows:
series.setCursorResultTableFormatter((builder, series, x, y, dataPoint) => {
// `dataPoint` has all same information as user supplied, size, rotation, value or anything.
return builder.addRow(x).addRow(y).addRow(dataPoint.value);
});
Please note that these custom properties (size, rotation, value, etc.) will only be included when cursor interpolation is disabled.
At this time v.3.2 is scheduled for late September, but this could change.
2nd question about changing shape of point series, we currently don't have active plans to change this, but when there is enough motivation it will be improved on.
I have the problem that years are not labeled correctly in my Bar Chart with Negative Values:
If I am using dates above 1894 everything works fine, but if i use dates that's like
"date": "1846"
the lables are just replaced by ":00".
I am using d3.v4.min.js. Data comes from a simple JSON.
This example is used as a basis: https://bl.ocks.org/WillTurman/9c4142944f6132855fd318350f552b7b
How can I change this
var parseDate = d3.timeParse("%Y");
so it also labels years below 1895?
The code appears to work in Firefox, but not Chrome (v68). I haven't checked other browsers, in any event, there is a problem.
The issue is in the axis, dates are otherwise handled appropriately: the graph is displayed as it should be. Specifically, the issue is in the default axis tick format function - after all the axis is created properly too - only the tick labels are in the wrong format.
For whichever reason (I haven't dug into it yet), the default tick format behavior appears to differ between Firefox and Chrome with respect to the dates and axis you are using. This can be solved by specifying your own tick format:
var timeFormat = d3.timeFormat("%Y");
var xAxis = d3.axisBottom(x)
.tickFormat(timeFormat)
This should give you something like:
var width = 600, height = 200;
var start = "January 1, 1600";
var end = "January 1, 2000";
var parse = d3.timeParse("%B %d, %Y");
var format = d3.timeFormat("%Y");
var scale = d3.scaleTime()
.domain([parse(start),parse(end)])
.range([10,width-10]);
var axis = d3.axisBottom(scale)
.tickFormat(format);
d3.select("body")
.append("svg")
.attr("width",width)
.attr("height",height)
.append("g")
.attr("transform","translate(0,100)")
.call(axis);
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
And here's an example using your example.
If you want to format the date differently (I'm using just the year in this example), take a look at d3's time formatting specifiers here.
When I call the plot() function the resulting plot always has a fixed size when it opens in my browser. I have tried to pass a layout argument to the function in many forms but it always throws an "unhandled layout type" error.
Example code:
using Plots
plotly()
data = rand(10)
plot(data, layout = [:autosize=false, :width = 500, :height = 500])
plot(data, layout = [autosize=false, width = 500, height = 500])
plot(data, layout = ["autosize"=>false, "width" => 500, "height" => 500])
Is there anyone that knows how to pass this layout argument correctly?
This can be done be specifying not a layout argument but the argument size:
plot(data, size = (width, height))
The layout argument I was referring too is used in the Plotly documentation that only applies when calling Plotly.plot, and not when you call Plots.plot with the plotly backend selected. The Plots.plot call translates its own set of arguments correctly to the selected backend.
For reference on the different usages:
http://docs.juliaplots.org/latest/attributes/
https://plot.ly/julia/setting-graph-size/
I found this answer
[Octave : How to change line color and width in drawRect
how to change the color in drawRect.
When I try the same for drawArrow, I get:
h=drawArrow(0,0,3,1,1,1,1,1);
h =
scalar structure containing the fields:
body = -12.469
head = -11.925
set(h,'color','r');
error: octave_base_value::array_value():
wrong type argument 'scalar struct'
error: set: H must be a graphics handle
What I am doing wrong here? For me it looks the same.
Thanks
Karl
You really should mention that you are using the octave-forge geometry package. drawArrow returns a struct with handles for the arrow body and head (as shown by your code) so you can and have to set them separately:
pkg load geometry
h = drawArrow (0,0,3,1,1,1,1,1);
set (h.body, "color", "r")
set (h.head, "facecolor", get(h.body, "color"))
You can also set a border around the head with "edgecolor"
Using shiny and rCharts to create a dashboard app, I need to pass raw javascript (not a string) to the Highcharts object.
Given this list
series <- list(data = list(c(0, 0), c(100, 0), c(100, 100)),
type = 'polygon',
color = 'Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get()')
I need to generate this JSON
{series:[{
data: [[0, 0], [100, 0], [100, 100]],
type: 'polygon',
color: Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get()
}]
}
but I can't find any way to prevent RJSONIO or jsonlte from quoting the value of the color property
shiny providers the JS() for wrapping literal javascript but RJSONIO ignores it and jsonlite complains about a missing a asJSON method for class JS_EVAL.
Is there some other way to selective prevent quoting of toJSON output?
You need support from the rCharts author. Two approaches:
The easy approach: use the htmlwidgets framework. Then all you need to do is put your JS code in htmlwidgets::JS(). The JS code will be preserved and evaluated automatically.
The harder approach: reinvent what we have done in htmlwidgets. I don't see why anybody ever wants to do this. Anyway, in case you care about the gory details, what we did were basically:
JS() adds a class JS_EVAL to the string, and we figure out the locations of such strings (e.g. series[2].color);
On the JavaScript side, find and eval() those strings;
The reason you cannot do this with json libraries is that your code is obviously not JSON but JavaScript. A hack would be to treat the literal string as if it were json:
color <- 'Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0.5).get()'
class(color) <- 'json'
series <- list(data = list(c(0, 0), c(100, 0), c(100, 100)),
type = 'polygon',
color = color)
jsonlite::toJSON(series, json_verbatim = TRUE, auto_unbox = TRUE)