I have a 2D dojox.chart. I want to label tick marks on the X axis with dates that have time and date on separate lines. Is there a way to achieve that?
Yes, there is quite a simple way. Just add a <br/> tag between your date and time in your labelFunc or in the text for values that you generate:
labelFunc: function(value){
return value +"<br/>"+"sometext";
}
Related
Lost as I can be on how to control hover text with embedded data.
Non-dataframe scenario
In one case, I am passing a list of dicts to a plotly express (scatter) plot, having the shape:
list[dict[str, float]]
and I would like the hover text for each point to include its key from the dict inside my own domain-specific phrasing for the hover text.
When not tampering with the hover text, the default hover text showing up includes the key following the string "variable", and the x and y values being called "index" and "value" accordingly there in the default hover text. Obviously the x value is just the index of the dict from the list for input shaped as in my input type.
But incorporating these values with names bearing the semantics of the data seems to pose a challenge, as including something like follows does not really plug in (by substitution) anything but the x and y values in the percent prefix bracelets:
fig.update(data=[{'hovertemplate': 'distance: %{y} (class %{variable})'}])
For example, %{variable} will show as just the string as is, it will not substitute this string with the value of what the default hover text calls "variable".
How would I incorporate the "variable" value, as called in the default hover text, in my own hover text specification?
I went through numerous documentation pages where this is accomplished via plotly's non-express api or other ways which didn't seem to work for me. It's in general elusive to adapt any of the dataframe based solutions to my dataframe-sidestepping case. I wonder if there's an idiomatic way.
DataFrame based scenario
In another case, switching to dataframe input, I still battle to get the desired column name be recognized as, I wander in the plurality of ways to handle hover text and data for plotly:
fig = px.scatter(df, x='x', y='distance', color='class')
fig.update(data=[{'hovertemplate': 'distance: %{y} class %{class}'}])
fig.show()
― %{class} in the above dataframe oriented approach, is obviously not the proper way to select the class column's value for the hover data. How would I bring in the value of the desired dataframe column name into the hover text?
Looking for suggestions on how I can modify the example dimple.js code in link below so the output is a filled/unfilled circle depending on the value of the 'Channel' variable?
http://dimplejs.org/examples_viewer.html?id=bubbles_vertical_grouped
Picture below is an example of the result I am looking to achieve.
result looking for
You can just do:
chart.assignColor("Supermarkets", "transparent", "blue");
Where the third parameter is whatever you want the outline colour to be. If you want thicker borders like your picture you can do that after drawing with:
svg.selectAll("circle").style("stroke-width", 5);
To be a bit more specific you can assign the series to a variable and access them that way:
var series = myChart.addSeries("Channel", dimple.plot.bubble);
myChart.draw();
series.shapes.style("stroke-width", 5);
Or you can set the stroke-width in CSS.
I am trying to plot a list of 30.000 values. The name of the list is "velocity_x". I just plot them with the following command:
plot(velocity_x,'r')
the result is shown in the image below (do not pay attention to the dashed line)
Since I am using that command line, it creates automatically a x-axis of length 30.000. What I would like to do is changing the range of my x-axis in such a way to show the time(s) instead of the iterations where t = 0.0002 * iteration.
You could use linspace:
a=np.linspace(0,6,len(velocity_x))
plot(a, velocity_x, 'r' )
You can set the values by setting 'Xticklabel' see here.
You want to do something like
h=gca; %get current axis if you dont have it as a handle already.
set(h, 'Xticklabel', 0:5000*0.0002:5000*0.0002*7); %set correct ticks.
You could also try something along the lines of
plot( [i*0.0002 for i in range(len(velocity_x))], velocity_x, 'r' )
I have a case where data presented on the chart is gathered in five minutes interval during the working hours, while at night it stays idle. When the chart presents data from a couple of days, there are obviously a flat lines between days (during nights).
Using category axis solves the problem with long steady lines during nights. However using time axis I was able to format date and use time interval property.
How can I do that using category axis? I mean formatting tick labels and achieve similar behaviour to using time intervals?
That is how it looks like at the moment using category axis:
I would like to present just one tick for every day, properly formatted.
Thank you in advance for any help.
You can do this by using a grouped category axis, It will involve a little manipulation of your dates into a separate time part and day part using some code like this:
// Create a d3 parser for this particular date format, this may not be relevant
// if you already have actual dates
var inFormat = d3.time.format("%Y-%m-%d %H:%M");
// Create a d3 parser for the day and time formats we are going to use
var dayFormat = d3.time.format("%d %b"),
timeFormat = d3.time.format("%H:%M");
// Add some code to manipulate the date into 2 separate fields
// because this is a category axis you need to handle formatting here
// category axes use text content
data.forEach(function (d) {
// Convert the date to an actual date, you may not need to do this if
// you already have date objects in your data
var inDate = inFormat.parse(d.Date);
// Add a new field for the time portion
d["Day"] = dayFormat(inDate);
d["Time"] = timeFormat(inDate);
}, this);
Here it is in context doing what I think you want:
http://jsfiddle.net/87GHM/1/
I'm working with core-plot and having problem with the x axis' customization .
I want x axis' labels to display some dates but they don't have an equal difference . For example , the dates may be like this : 2012-05-06 , 2012-06-08 , 2012-07-21 ... So I think I can not set the axis labels by setting the major interval . Can anyone tell me the way to do this ? Any suggestion will be appreciated !
Yes,If those dates are consecutive value means You can achieve this while creating a custom label. You can add your consecutive dates into an Array and set this array to majorTickLocations property of your X axis.
following line add into your custom label generation method. customStick is value u wanted to set.
[customTick addObject:customStick];
add this line in your axis property set.
axisSet.xAxis.majorTickLocations = [NSSet setWithArray:customTick];