0
votes

In my application I am replacing old charts with google charts

Old chart looks like this

enter image description here

I can easily create column chart using this reference https://developers.google.com/chart/interactive/docs/gallery/columnchart

In above we can see one pink line on column chart with value "2" at top. This is gridline which depends on some condition. If condition is true then I have to show that grid line with pink color & its value at top.

how can I do this with google column chart ?

1
This link may be usefull for you,http://cran.r-project.org/web/packages/googleVis/vignettes/googleVis_examples.htmlAishwaryaVengadesan

1 Answers

0
votes

I am still getting to grips with these charts (via googleVis) in R.

1) Possible route I can suggest - Use annotation text This may help signal which bars are important, please take a look at @mages excellent examples about using roles.

See mages Sales example (I realise this is for R - its just to help you find example on the webpage link above where he has the chart shown):

dat <- data.frame(Year=2010:2013, 
                  Sales=c(600, 1500, 800, 1000),
                  Sales.annotation=c('First year', NA, NA, 'Last Year'),
                  Sales.annotationText=c('$600K in our first year!',
                                       NA,
                                       NA,
                                       '$1M in sales last year.'))      

plot(
  gvisLineChart(dat, xvar='Year', 
                  yvar=c('Sales',
                         'Sales.annotation',
                         'Sales.annotationText'),
                         options=list(annotations = "{style:'line'}")
  )
)

On that page you will see how the lines are highlighted. You could use this trigger condition to create a vector with text you need e.g. ("triggered flag", NA, NA, NA) and then use as annotation text.

2) Another option is using emphasis or certainty on lines/columns to change the formatting that depend on this condition.

See mages R code on this as well.

dat <- data.frame(Year=2010:2013,
                  Sales=c(600, 1500, 800, 1000),
                  Sales.html.tooltip=c('$600K in our first year!',
                                       'Sunspot activity made this our best year ever!',
                                       '$800K in 2012.',
                                       '$1M in sales last year.'),
                  Sales.certainty=c(TRUE, FALSE, TRUE, FALSE))
plot(
  gvisColumnChart(dat, xvar='Year', 
                  yvar=c('Sales', 'Sales.certainty')
  )
)

Not quite what you wanted (nor in right language!) but flags options to explore (and help others).