dvandersluis / amcharts.rb

Ruby/Rails wrapper for Amcharts
MIT License
12 stars 9 forks source link

Upgrade Amcharts to 3.21.1 #8

Closed rvracaric closed 7 years ago

rvracaric commented 7 years ago

Specifying a legend position via JSON is fine:

var chart = AmCharts.makeChart("chartdiv", {
   "type": "serial",
   ...
   "legend": { "position": "right" }
}

stacked_column_chart_-_jsfiddle

But adding a legend as the gem is doing via addLegend(), messes up the positioning:

var legend = new AmCharts.AmLegend();
legend.position = "right";
chart.addLegend(legend, null);

stacked_column_chart_-_jsfiddle

The problem is passing null as the legend div. It seems this started being an issue in Amcharts 3.20.18.

dvandersluis commented 7 years ago
  1. Why'd you change the version to be a double quoted string instead of a single quoted string?
  2. The thor task doesn't clean up files that are no longer in use, are there any?
  3. Anything in /examples/ shouldn't be included.
rvracaric commented 7 years ago
  1. The thor task was crashing as it looks for double quoted string (which it then replaces by a new double quoted string). Just thought it's faster to change the current version's quotes (so the task can run), than to modify its regular expression.

  2. Hm, let me check this. I'll try removing all old files first.

  3. Okay, will remove /examples/.

rvracaric commented 7 years ago

re: 3. I removed examples folders

re: 2. Before upgrading to 3.21.1 I removed all the files and folders in vendor/assets/images, vendor/assets/javascripts, and vendor/assets/images/stylesheets. So there should be no files no longer in use.

After cleaning up the old files and upgrading to 3.21.1, noticed that Export feature was not working anymore. Export was redesigned in Amcharts 3.14.

So I had to tweak app/views/amcharts/_export.erb and app/helpers/amcharts/amcharts_helper.rb a bit to get the Export plugin working again.

More tweaks are needed in the future if, for example, loading PDF library manually if PDF menu is enabled is required. Right now, the Export plugin loads libraries needed for its operation automatically (recommended by Amcharts).