Custom Line Chart - any tool

Asked

Viewed 132 times

3

I need to create a line chart (python, R or even excel), where each line is a product category, the y axis is the sale and x is the time. If the sale is above the finish line, the line stays of one color, if it has below, another color. It would be a way in the timeline chart I show whether that category is above or below the target for the whole period.

  • Hey, I don’t know how to graph by pulling the data from the python database, but you can pull the data from the database through python and put it in a graph in javascript.

  • https://www.highcharts.com/demo/line-basic Highcharts has nice, easy-to-handle graphics.

  • 3

    Unfortunately, this question cannot be reproduced by anyone trying to answer it. Please, take a look at this link and see how to ask a reproducible question in R. So, people who wish to help you will be able to do this in the best possible way.

  • Welcome(a). Please do the [tour], then read How we should format questions and answers? and create a [mcve] for the question. Because the question is too wide and when you are more specific, there are more chances of your question being answered correctly.

1 answer

1

Difficult to answer with little information, but follows an attempt

#os dados
set.seed(123)
tss=abs(matrix(rnorm(50*3,1000,1000),ncol=3))
meta=colMeans(tss)*c(0.8,1.2,1.4) # suposto
mcol=apply(tss-meta,2,function(vx)ifelse(vx>=0,"Sup.Meta","Inf.Meta"))

library(ggplot2)
library(reshape)

tssdf=data.frame(tss)
tssdf$data=1:nrow(tssdf)
#melt(mcol)
tssdfm=melt(tssdf, id = "data")
tssdfm$supmeta=factor(melt(mcol)$value)

ggplot(data=tssdfm, aes(x=data, y=value, colour=variable))  +theme_bw() + geom_line()+
  geom_point(aes(col=supmeta), size=3) 

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.