I need to custom my x-axis label so that it show the label in two lines. I've tried this:
let labelFormat = new IgxTimeAxisLabelFormatComponent();
labelFormat.format = "dd/MM/yyyy" + "\n" + "hh:mm:ss";
this.xAxis.labelFormats.add(labelFormat);
But the result is that it stays on a single line, like this:
.
Have you any advice?
Unfortunately, I dont think that is possible simply through the API. The label format method should be used for common formats like 'MM/dd/yy' or the ones that you are using.
BUT, if you want to change the actual appearance of the label then formatLabel should be the path to follow. While creating an example for you, I realized that the returned value is of type string, so the end result would not be suitable for you again.
public xAxis_FormatLabel(item: any) {
return item.Country + " \n" + "some other string";
}
Live demo:
https://stackblitz.com/edit/github-exckfz-bsvpqs?file=src%2Fapp%2Fdata-chart-type-stacked-column-series%2Fdata-chart-type-stacked-column-series.component.ts
Here you can find all the settings related to the Axis
Hi I am not able to catch slot values in my custom action I have made a custom action that returns a slot set of the clinks ie. links that are correspoding to colors like red blue or black The clinks is a list of dict.Here is my run method
def run(self, dispatcher, tracker, domain):
clinks = [ {“color”: “red”,“link”:“Amazon.com: red shirts”}, {“color”: “blue”, “link”: “Amazon.com: blue shirts”}, {“color”:“black”,“link”:“Amazon.com: black shirts”} ]
color = tracker.get_slot(“color”)
print(color)
link = [c[“link”] for c in clinks if c[“color”] == color]
print(link)
dispatcher.utter_message("{}".format(link))
return [SlotSet("clinks", clinks)]
I am using spacy pipeline But the output of server shows that value of slot is None How to solve this problem
I have created a Shiny app that takes user input and creates a CA plot. It works just fine when I run the app locally, but for some reason when I deploy the dashboard, the image of the plot won't appear. I can see in the logs that the data uploading and reformatting into a proper data frame is working just fine, but the plot itself is failing to render.
Does anyone know why this might be? I posted my code below (you'll see some print() lines in my code that was used for debugging). Any help would be greatly appreciated!
#PERCEPTUAL MAPPING DASHBOARD
library(FactoMineR)
library(factoextra)
library(SensoMineR)
library(shinythemes)
library(ca)
ui <- fluidPage(theme = shinytheme("darkly"),
# Application title
titlePanel("Perceptual Map Dashboard"),
sidebarLayout(
# Sidebar with a slider and selection inputs
sidebarPanel(
#Excel doc row and column names
numericInput(inputId="startcol",label="Input start column of CSV file:",value="", min=1,max=10000),
numericInput(inputId="endcol",label="Input end column of CSV file:",value="", min=1,max=10000),
#Inputing brands and emotions
br(),
numericInput(inputId = "rownums",label = "How many emotions/characteristics are you evaluating?",value = "", min = 1,max = 10000),
br(),
h6("Note: Please enter brands and emotions/characteristics in the order that they appear in the excel document exported from Survey Gizmo."),
textInput ( 'brands', 'List the brands included in your perceptual map (separated by commas):', value=""),
textInput ( 'emotions', 'List the emotions/characteristics included in your perceptual map (separated by commas):', value=""),
#Removing brands and emotions
#Select graph type
textInput(inputId="plottitle",label="Title your graph:"),
#Upload Excel Grid
fileInput(inputId = 'data', 'Upload CSV File',
accept=c('.csv')),
actionButton("go","Create Map")
),
# Visual Output
mainPanel(
wellPanel(h4('Visual'),
h5("Once your visual appears, just right click it to save it as a .png file.")),
plotOutput(outputId = "plot", width = "100%", height=500)
# downloadButton("downloadPlot", "Download Visual")
)
)
)
server <- function(input,output){
K <- eventReactive(input$go,{
x <- read.csv(input$data$datapath, header = F)
x[!is.na(x)] <- 1
x[is.na(x)] <- 0
x<-x[,as.numeric(input$startcol):as.numeric(input$endcol)]
column.sums<-colSums(x)
print(column.sums)
pmd.matrix<-matrix(column.sums, byrow = T, nrow=as.numeric(input$rownums))
pmd.df2<-as.data.frame(pmd.matrix)
colnames(pmd.df2) = unlist(strsplit(as.character(input$brands),","))
print(pmd.df2)
row.names(pmd.df2)= unlist(strsplit(as.character(input$emotions),","))
print(pmd.df2)
pmd.df2[-nrow(pmd.df2),]
print(pmd.df2)
fit <- CA(pmd.df2, graph=F)
return(fit)
})
p <- eventReactive(input$go,{
input$plottitle
})
output$plot<- renderPlot({
plot.CA(K(), col.row = "blue", col.col="black", cex=1, new.plot=T,
title=p())
})
}
shinyApp(ui = ui, server = server)
What I suggest to you is to check whether this issue is specific to your plot or if plot.CA is not working with shiny in general. Try to "deploy" (apparently, you don't use a webserver?) the following app
library(FactoMineR)
library(shiny)
data(children)
res.ca <- CA(children, col.sup = 6:8, row.sup = 15:18)
shinyApp(
fluidPage(plotOutput("plot")),
function(input, output, sesison) {
output$plot <- renderPlot({
plot.CA(res.ca)
})
}
)
If this does work, there might be something wrong with your model or maybe there are name collusions between the ca package and the FactorMineR package.
If this does not work, try the following instead
## use same data/libraries as above
myfile <- tempfile(fileext = ".png")
shinyApp(
fluidPage(imageOutput("plot")),
function(input, output, sesison) {
output$plot <- renderImage({
png(file = myfile)
plot.CA(res.ca)
dev.off()
list(src = myfile)
}, deleteFile = FALSE)
}
)
And see
Whether the app works now
Whether myfile gets created and contains reasonable contents.
In my server.R I have:
output$interactive <- renderIHeatmap(...
output$static <- renderPlot(...
Both of these render heatmaps, one interactive, one static. Is there a way that shiny can automatically choose to display the static heatmap if the row or column dimensions of the heatmap is greater than a specific number? So something like...
box(width = NULL, solidHeader = TRUE,
if (heatmap_rows<100) {
iHeatmapOutput('interactive')
} else {
plotOutput('static')
})
Thank you for your time. I apologize if this is unclear.
What you are looking for is conditionalPanel().
In server.R, you need to make an output variable that is the number of rows:
shinyServer(function(input,output,session){
output$heatmap_rows <- renderText(nrow(heatmap_data))
}
In your ui.R, you need to display that output somewhere. You can probably hide it cleverly with .css, but it has to actually go into the html of your page, or else you won't be able to condition on it with conditionalPanel.
So here's the general idea in ui.R:
shinyUI(fluidPage(
mainPanel(
#Note the output.heatmap_rows syntax. That's JavaScript.
conditionalPanel("output.heatmap_rows < 100",
iHeatmapOutput('interactive')
),
conditionalPanel("output.heatmap_rows >= 100",
plotOutput('static')
)
),
#This has to be somewhere on the page, and it has to render.
#Alter the css and make its' text the same color as the background.
verbatimTextOutput("heatmap_rows")
))
I haven't found a better way to condition on data from the output. You could probably hide all of that logic behind a uiRender in server.R as well.
I am designing a form using Google Scripting. I have two text boxes that need to hold time values, and I want to make sure the input is valid.
function setupTimeValidators(widget) {
var timeRe = /(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m/i;
var onValid = (UiApp.getActiveApplication().createClientHandler()
.validateMatches(widget, timeRe)
.forTargets(widget)
.setStyleAttribute("background", "#FFFFFF"));
var onInvalid = (UiApp.getActiveApplication().createClientHandler()
.validateNotMatches(widget, timeRe)
.forTargets(widget)
.setStyleAttribute("background", "#FFCCCC"));
widget.addKeyUpHandler(onValid);
widget.addKeyUpHandler(onInvalid);
}
The onInvalid parts changes the textbox background color as soon as I start typing in the textbox, but it never changes back to white when I get to 01:11 pm. (I have tested this with other values.)
I am sure my regular expression works, because I tested it like so:
function test() {
Browser.msgBox(/(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m/i.test("01:11 pm")); // true
Browser.msgBox(/(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m/i.test("00:11 pm")); // false
Browser.msgBox(/(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m/i.test("10:11 pm")); // true
Browser.msgBox(/(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m/i.test("10:90 pm")); // false
}
Any ideas what could be going on? Thanks!
You can't use a regex object with validateMatches or validateNotMatches.. you should use a string representation of the regex, as such:
var timeRe = "(0[1-9])|(1[0-2]):[0-5][0-9] ?[ap]m";
var flags = "i";
...
.validateMatches(widget, timeRe, flags)