Widget Tricks - ods-chart: Custom CSS Library

Default view

First, the default view, without any advanced options (ie. straight from the analysis tab).

Advanced options

Before hacking the CSS, several advanced option can help to optimize the display.

On ods-chart :

  • single-y-axis="true" : remove the Y axis label on the left. Or with the following additional parameter, rename it.

  • single-y-axis-label="Nb of sites" : rename the Y axis label on the left.

  • labels-x-length="20" : increase label length.

  • display-legend="false" : remove bottom legend BUT beware to create your own legend or chart description somewhere else. Specially for multilines charts.

On ods-chart-query :

  • category-colors={'x-value':'#FF0000'} : Set a specific color for each X value.

On ods-chart-serie :

  • label-y="Number of sites by Region" :
  • color="#FF0000" : Set a specific color for the serie of the chart.
  • display-values="true" : Display values on top of the serie.

ods-chart custom CSS library

This resource introduces a custom CSS library dedicated to ods-chart, it helps users to customize their charts easily by simply adding CSS classes to ods-chart tag. To install it, simply copy the CSS code of this resource, and paste it into your page.

CSS classes follows this pattern : value-[axis]-chartproperty.

Chart properties can be :

  • axisline
  • gridline
  • axisline-ticks
  • chart-series
  • chart-legend-dash
  • chart-legend-circle
  • values
  • legend

Axis can be x or y

For paths, like axislines, gridlines, ticks, chart series, legend dashes and chart legend circles, value can be :

  • small
  • medium
  • large
  • extralarge

For texts, like legends and values, value can be :

  • light
  • normal
  • bold

For paths and texts that can be colored, value can be :

  • lightgrey
  • darkgrey
  • black

Chart properties that can’t be disabled by ods-chart parameters, can be hidden with hide as the value

Other specific properties :

  • centered-tooltip : to center the text in mouse hover tooltip
  • transparent-background, remove-background, no-background, no-bg : get rid of the default white background.

Examples:

  • Hide Y values : hide-y-values
  • Hide X legend : hide-x-legend
  • Bold weight for Y values font : bold-y-values
  • Black color for Y legend font : black-y-legend
  • Larger stroke for chart series : large-chart-series
  • Extralarge dash in chart legend (for line/spline series) : extralarge-chart-legend-dash
  • etc…

Final touch with advanced CSS

To finish, specific CSS can be set on some chart elements, like linear gradient to modify line/spline areas and bars/columns.

This example cover the linear gradient, it is declared in the HTML, and applied through the CSS.

More example to come.