Add support for flotr2 as an alternative to Google Charts #166

Closed
wants to merge 9 commits into
from

Conversation

Projects
None yet
4 participants
@doozel
Contributor

doozel commented Apr 7, 2014

I have made changes adding the JavaScript charting library Flotr2 as an alternative to Google Charts. I think it is a much better alternative when you are using it in a corporate environment with no need for external calls. Toggle between Google Charts and Flotr2 in the gitblit.properties file: web.chartType = flotr2 or web.chartType = google. The default is google.

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 8, 2014

Owner

This is a somewhat frequent request so thanks for tackling it. It looks like the activity graphs are not working properly. If we can get those working properly, then I'll be more interested in merging.

Owner

gitblit commented Apr 8, 2014

This is a somewhat frequent request so thanks for tackling it. It looks like the activity graphs are not working properly. If we can get those working properly, then I'll be more interested in merging.

@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 8, 2014

Contributor

Which one of activity graphs aren't working? Which page?

On 8/04/2014 2:34 PM, James Moger wrote:

This is a somewhat frequent request so thanks for tackling it. It
looks like the activity graphs are not working properly. If we can get
those working properly, then I'll be more interested in merging.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 8, 2014

Which one of activity graphs aren't working? Which page?

On 8/04/2014 2:34 PM, James Moger wrote:

This is a somewhat frequent request so thanks for tackling it. It
looks like the activity graphs are not working properly. If we can get
those working properly, then I'll be more interested in merging.


Reply to this email directly or view it on GitHub
#166 (comment).

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 8, 2014

Owner

Repo summary page.

Owner

gitblit commented Apr 8, 2014

Repo summary page.

@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 8, 2014

Contributor

Can you send a screenshot? What repo are you looking at?

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 8, 2014

Can you send a screenshot? What repo are you looking at?

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 8, 2014

Contributor

I have just pushed the changes to fix the summary page.

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 8, 2014

I have just pushed the changes to fix the summary page.

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 8, 2014

Contributor

Also just fixed Metrics page

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 8, 2014

Also just fixed Metrics page

On 8/04/2014 2:53 PM, James Moger wrote:

Repo summary page.


Reply to this email directly or view it on GitHub
#166 (comment).

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 8, 2014

Owner

That looks much better. With all the graphing lib choices, why flotr2? I have nothing against it, just never heard of it.

Owner

gitblit commented Apr 8, 2014

That looks much better. With all the graphing lib choices, why flotr2? I have nothing against it, just never heard of it.

@marcomsousa

This comment has been minimized.

Show comment Hide comment
@kwoot

This comment has been minimized.

Show comment Hide comment
@kwoot

kwoot Apr 8, 2014

Cool. Thanks!

op 08-04-14 15:46, Marco Sousa schreef:

here do you have the answer:
http://swizec.com/blog/flotr2-my-favorite-javascript-graph-library/swizec/4558


Reply to this email directly or view it on GitHub
#166 (comment).

Jeroen Baten | EMAIL : JBATEN@I2RS.NL
____ _ __ | web : www.i2rs.nl
| )|)( | tel : +31 (0)345 - 75 26 28
|/_| __) | Molenwindsingel 46, 4105 HK, Culemborg, the Netherlands

kwoot commented Apr 8, 2014

Cool. Thanks!

op 08-04-14 15:46, Marco Sousa schreef:

here do you have the answer:
http://swizec.com/blog/flotr2-my-favorite-javascript-graph-library/swizec/4558


Reply to this email directly or view it on GitHub
#166 (comment).

Jeroen Baten | EMAIL : JBATEN@I2RS.NL
____ _ __ | web : www.i2rs.nl
| )|)( | tel : +31 (0)345 - 75 26 28
|/_| __) | Molenwindsingel 46, 4105 HK, Culemborg, the Netherlands

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 8, 2014

Owner

@doozel Here is what I'd like to do, if you are willing...

  1. tweak the activity graphs to use the colors of the original graphs - those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over points - although I do like that feature. If this becomes a layout or size problem, we'll skip it.
  3. Add % to the pie chart labels, as an engineer unit-less numbers make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't see a reason to continue offering GoogleCharts with a working, self-hosted charting solution that is faster and substantially equivalent.
  5. Is there a way to specify an onclick handler for the pie charts? I've long had this idea to jump to the repo summary page from a pie chart click. We'll skip it if can't be done or if it requires ugly hacks.
Owner

gitblit commented Apr 8, 2014

@doozel Here is what I'd like to do, if you are willing...

  1. tweak the activity graphs to use the colors of the original graphs - those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over points - although I do like that feature. If this becomes a layout or size problem, we'll skip it.
  3. Add % to the pie chart labels, as an engineer unit-less numbers make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't see a reason to continue offering GoogleCharts with a working, self-hosted charting solution that is faster and substantially equivalent.
  5. Is there a way to specify an onclick handler for the pie charts? I've long had this idea to jump to the repo summary page from a pie chart click. We'll skip it if can't be done or if it requires ugly hacks.
@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 8, 2014

Contributor

Only because I have used it before and I think it works well.

On 8/04/2014 11:44 PM, James Moger wrote:

That looks much better. With all the graphing lib choices, why flotr2?
I have nothing against it, just never heard of it.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 8, 2014

Only because I have used it before and I think it works well.

On 8/04/2014 11:44 PM, James Moger wrote:

That looks much better. With all the graphing lib choices, why flotr2?
I have nothing against it, just never heard of it.


Reply to this email directly or view it on GitHub
#166 (comment).

@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 9, 2014

Contributor

The x-axis labels were painful, that is why I excluded them. 1, 3 & 4 I
can do, I will also look at how to do the click event.

On 9/04/2014 12:17 AM, James Moger wrote:

@doozel https://github.com/doozel Here is what I'd like to do, if
you are willing...

  1. tweak the activity graphs to use the colors of the original graphs
    • those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over
    points - although I do like that feature. If this becomes a layout
    or size problem, we'll skip it.
  3. Add /%/ to the pie chart labels, as an engineer unit-less numbers
    make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't
    see a reason to continue offering GoogleCharts with a working,
    self-hosted charting solution that is faster and substantially
    equivalent.
  5. Is there a way to specify an onclick handler for the pie charts?
    I've long had this idea to jump to the repo summary page from a
    pie chart click. We'll skip it if can't be done or if it requires
    ugly hacks.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 9, 2014

The x-axis labels were painful, that is why I excluded them. 1, 3 & 4 I
can do, I will also look at how to do the click event.

On 9/04/2014 12:17 AM, James Moger wrote:

@doozel https://github.com/doozel Here is what I'd like to do, if
you are willing...

  1. tweak the activity graphs to use the colors of the original graphs
    • those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over
    points - although I do like that feature. If this becomes a layout
    or size problem, we'll skip it.
  3. Add /%/ to the pie chart labels, as an engineer unit-less numbers
    make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't
    see a reason to continue offering GoogleCharts with a working,
    self-hosted charting solution that is faster and substantially
    equivalent.
  5. Is there a way to specify an onclick handler for the pie charts?
    I've long had this idea to jump to the repo summary page from a
    pie chart click. We'll skip it if can't be done or if it requires
    ugly hacks.


Reply to this email directly or view it on GitHub
#166 (comment).

Removed old Google Charts code, add percentage sign to pir charts, ad…
…justed colors and added click event to repository pie charts
@doozel

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 9, 2014

Contributor

I have made the changes below (1, 3, 4 & 5), I could add a click event
to the repository pie charts. I couldn't do it for the author as you
need to also specify a repository name for the search to work.

On 9/04/2014 12:17 AM, James Moger wrote:

@doozel https://github.com/doozel Here is what I'd like to do, if
you are willing...

  1. tweak the activity graphs to use the colors of the original graphs
    • those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over
    points - although I do like that feature. If this becomes a layout
    or size problem, we'll skip it.
  3. Add /%/ to the pie chart labels, as an engineer unit-less numbers
    make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't
    see a reason to continue offering GoogleCharts with a working,
    self-hosted charting solution that is faster and substantially
    equivalent.
  5. Is there a way to specify an onclick handler for the pie charts?
    I've long had this idea to jump to the repo summary page from a
    pie chart click. We'll skip it if can't be done or if it requires
    ugly hacks.


Reply to this email directly or view it on GitHub
#166 (comment).

Contributor

doozel commented Apr 9, 2014

I have made the changes below (1, 3, 4 & 5), I could add a click event
to the repository pie charts. I couldn't do it for the author as you
need to also specify a repository name for the search to work.

On 9/04/2014 12:17 AM, James Moger wrote:

@doozel https://github.com/doozel Here is what I'd like to do, if
you are willing...

  1. tweak the activity graphs to use the colors of the original graphs
    • those are the Gitblit colors - the dark navy blue & the orange.
  2. I'd like to see x-axis labels so I don't have to mouse-hover over
    points - although I do like that feature. If this becomes a layout
    or size problem, we'll skip it.
  3. Add /%/ to the pie chart labels, as an engineer unit-less numbers
    make me cringe. :)
  4. Dump all the GoogleChart code, including your new setting. I don't
    see a reason to continue offering GoogleCharts with a working,
    self-hosted charting solution that is faster and substantially
    equivalent.
  5. Is there a way to specify an onclick handler for the pie charts?
    I've long had this idea to jump to the repo summary page from a
    pie chart click. We'll skip it if can't be done or if it requires
    ugly hacks.


Reply to this email directly or view it on GitHub
#166 (comment).

+ String displayFormat = "MMM dd";
+ if(metrics.size() > 0 && metrics.get(0).name.length() == 7){
+ df = new SimpleDateFormat("yyyy-MM");
+ displayFormat = "MMM";

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 9, 2014

Owner

Let's change this to displayFormat = "yyyy MMM";

@gitblit

gitblit Apr 9, 2014

Owner

Let's change this to displayFormat = "yyyy MMM";

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 9, 2014

Owner

This looks great! I have a few more tweaks I'd like before merging.

  1. Move the new resources into a flotr or flotr2 dir
  2. The old graph didn't show a blue circle for every data point. Those blue circles actually represent tags so there should two series, I suppose. The normal points (orange line) and the tag points (discrete blue dots). The tag points are determined by metric.tag > 0. I don't have the tag labels, just a count. When we restore tag indicators, then we're ready to merge.
Owner

gitblit commented Apr 9, 2014

This looks great! I have a few more tweaks I'd like before merging.

  1. Move the new resources into a flotr or flotr2 dir
  2. The old graph didn't show a blue circle for every data point. Those blue circles actually represent tags so there should two series, I suppose. The normal points (orange line) and the tag points (discrete blue dots). The tag points are determined by metric.tag > 0. I don't have the tag labels, just a count. When we restore tag indicators, then we're ready to merge.
getString("gb.repository"), getString("gb.commits"));
for (Metric metric : repositoryMetrics.values()) {
chart.addValue(metric.name, metric.count);
}
chart.setShowLegend(false);
+ chart.setClickUrl("../summary/");

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 9, 2014

Owner

String url = urlFor(SummaryPage.class, null).toString() + "?r=";
chart.setClickUrl(url);

@gitblit

gitblit Apr 9, 2014

Owner

String url = urlFor(SummaryPage.class, null).toString() + "?r=";
chart.setClickUrl(url);

getString("gb.repository"), getString("gb.commits"));
for (Metric metric : repositoryMetrics.values()) {
chart.addValue(metric.name, metric.count);
}
chart.setShowLegend(false);
+ chart.setClickUrl("summary/");

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 9, 2014

Owner

String url = urlFor(SummaryPage.class, null).toString() + "?r=";
chart.setClickUrl(url);

@gitblit

gitblit Apr 9, 2014

Owner

String url = urlFor(SummaryPage.class, null).toString() + "?r=";
chart.setClickUrl(url);

+ SimpleDateFormat df = new SimpleDateFormat(dateFormat);
+ df.setTimeZone(getTimeZone());
+
+ // Sort the values first

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 9, 2014

Owner

Sorting is unnecessary as the data is already sorted by the metrics generator. And in fact, this sort method doesn't always work and can generate interesting line graphs. :) You should be safe to toss this.

@gitblit

gitblit Apr 9, 2014

Owner

Sorting is unnecessary as the data is already sorted by the metrics generator. And in fact, this sort method doesn't always work and can generate interesting line graphs. :) You should be safe to toss this.

This comment has been minimized.

Show comment Hide comment
@doozel

doozel Apr 10, 2014

Contributor

All of those changes are complete.

On 9/04/2014 11:00 PM, James Moger wrote:

In src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java:

  •       String valueName) {
    
  •   super(tagId, title, keyName, valueName);
    
  • }
  • @override
  • protected void appendChart(StringBuilder sb) {
  •   String dName = "data_" + dataName;
    
  •   sb.append("var labels_" + dataName + " = [");
    
  •   if(xAxisIsDate){
    
  •       // Generate labels for the dates
    
  •       SimpleDateFormat df = new SimpleDateFormat(dateFormat);
    
  •       df.setTimeZone(getTimeZone());
    
  •       // Sort the values first
    

Sorting is unnecessary as the data is already sorted by the metrics
generator. And in fact, this sort method doesn't always work and can
generate interesting line graphs. :) You should be safe to toss this.


Reply to this email directly or view it on GitHub
https://github.com/gitblit/gitblit/pull/166/files#r11433892.

@doozel

doozel Apr 10, 2014

Contributor

All of those changes are complete.

On 9/04/2014 11:00 PM, James Moger wrote:

In src/main/java/com/gitblit/wicket/charting/Flotr2LineChart.java:

  •       String valueName) {
    
  •   super(tagId, title, keyName, valueName);
    
  • }
  • @override
  • protected void appendChart(StringBuilder sb) {
  •   String dName = "data_" + dataName;
    
  •   sb.append("var labels_" + dataName + " = [");
    
  •   if(xAxisIsDate){
    
  •       // Generate labels for the dates
    
  •       SimpleDateFormat df = new SimpleDateFormat(dateFormat);
    
  •       df.setTimeZone(getTimeZone());
    
  •       // Sort the values first
    

Sorting is unnecessary as the data is already sorted by the metrics
generator. And in fact, this sort method doesn't always work and can
generate interesting line graphs. :) You should be safe to toss this.


Reply to this email directly or view it on GitHub
https://github.com/gitblit/gitblit/pull/166/files#r11433892.

@gitblit

This comment has been minimized.

Show comment Hide comment
@gitblit

gitblit Apr 10, 2014

Owner

I pushed your commits to ticket-43 for preservation, squashed them, and merged to master. Thanks for working on this, you've just closed issue-283.

Owner

gitblit commented Apr 10, 2014

I pushed your commits to ticket-43 for preservation, squashed them, and merged to master. Thanks for working on this, you've just closed issue-283.

@gitblit gitblit closed this Apr 10, 2014

gitblit added a commit that referenced this pull request Sep 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment