Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2766181
added new type of chart, added support for axes title in extendedBarC…
eddiman Feb 5, 2021
7ebd047
added y axis ticks in extended bar chart, fixed issues with tick and …
eddiman Feb 9, 2021
f14990d
removed debug comments and logging, added some code comments
eddiman Feb 9, 2021
e64335c
added support for chart title, addded more var and function comments,…
eddiman Feb 9, 2021
a413f37
replaced all double quotation with the single quotation mark to be in…
eddiman Feb 9, 2021
748beb4
added language translations to norwegian b
eddiman Feb 9, 2021
89181ab
fixed minor issues
eddiman Feb 10, 2021
592dbd1
Merge pull request #1 from NDLANO/feature/barchart-extension
eddiman Feb 10, 2021
73331ea
added support for line chart
eddiman Feb 10, 2021
d560d02
added color override support and hover indicator on line chart
eddiman Feb 11, 2021
ea46558
added minor fixes to labels on line diagram
eddiman Feb 15, 2021
2def298
added comments to line chart
eddiman Feb 15, 2021
e6ac302
added translations
eddiman Feb 15, 2021
c9bcfa8
fixed more comments in line chart
eddiman Feb 15, 2021
ef0f7b8
Merge pull request #2 from NDLANO/feature/line-chart
eddiman Feb 15, 2021
a2c3c17
fixed nb lang support, minor changes in semantics, and fixed .en json…
eddiman Feb 15, 2021
940da39
restructured semantics for easier adding missing fields to rest of la…
eddiman Feb 16, 2021
7a520b0
added missing pt-br translation
eddiman Feb 16, 2021
a7ec45d
removed unnecessary lines in lang jsons
eddiman Feb 16, 2021
7424787
Merge pull request #4 from NDLANO/fix/lang-fix
eddiman Feb 17, 2021
3247fbc
bump patch version
kentis Feb 18, 2021
95550b0
Merge pull request #5 from NDLANO/feature/bump_patch_version
kentis Feb 18, 2021
31a557f
fixed default color for line and offsets for no chart title and y axi…
eddiman Feb 18, 2021
8bcfaaa
added default color to lineGroup
eddiman Feb 18, 2021
72b5d96
Update line.js inline condittionals
eddiman Feb 18, 2021
09f9fc7
Merge pull request #6 from NDLANO/fix/chart-offset-and-color
eddiman Feb 18, 2021
4233c88
fixed offset for chart when no chart is present
eddiman Feb 19, 2021
7b433cb
Merge pull request #7 from NDLANO/fix/extended-bar-no-title-offset
eddiman Feb 19, 2021
f0d4c7d
fixed a minor offset issue of x axis tick when chart title is not def…
eddiman Feb 19, 2021
4fb7e4e
Merge pull request #8 from NDLANO/fix/offset-x-axis-tick
eddiman Feb 19, 2021
fd9cf70
fixed line and x axis alignment issues, fixed labels and tabbing and …
eddiman Mar 10, 2021
d28a52c
Merge pull request #9 from NDLANO/feature/line-chart-upgrade
eddiman Mar 11, 2021
7fa8320
fixed bar resizing, added tabbing to bars
eddiman Mar 11, 2021
7ee2870
fix bar graph alignment and resize issue
eddiman Mar 11, 2021
c930f73
cleaned x axis group setting
eddiman Mar 11, 2021
676956a
Merge pull request #10 from NDLANO/feature/line-chart-upgrade
eddiman Mar 11, 2021
ac12a20
Merge branch 'master' into feature/extended-bar-upgrade
eddiman Mar 11, 2021
dc8cea1
cleaned up xAxis group translation var setting
eddiman Mar 11, 2021
4a45a56
Merge branch 'master' into feature/extended-bar-upgrade
eddiman Mar 11, 2021
e93d089
added some comments for explaining som vars
eddiman Mar 11, 2021
4a8859d
removed some old comments in line.js
eddiman Mar 11, 2021
5d183a2
bumped patchversion
eddiman Mar 11, 2021
278aed9
Merge remote-tracking branch 'origin/master' into feature/extended-ba…
boyum Mar 12, 2021
3c8bc4e
fixed line chart offsett issue
eddiman Mar 12, 2021
2f9fa37
added horizontal padding
eddiman Mar 12, 2021
41973bd
added horizontal padding, moved bar texts to top of bar, changed defa…
eddiman Mar 12, 2021
ece74bf
Update line.js
eddiman Mar 12, 2021
4e37939
Merge pull request #12 from NDLANO/fix/line-chart-offset
eddiman Mar 12, 2021
523cd84
Merge pull request #11 from NDLANO/feature/extended-bar-upgrade
eddiman Mar 12, 2021
ea5dfbb
bumped patchnumber and added support for showWhen widget when chart …
eddiman Mar 12, 2021
b717099
fixed height issue when tooletip text height is defined by external s…
eddiman Mar 15, 2021
860446d
css styling for fixing height issue when tooletip text height is defi…
eddiman Mar 15, 2021
9bd1370
fixed minor hover issue
eddiman Mar 15, 2021
4438e63
fixed issue with bar text label alignment
eddiman Mar 15, 2021
5fe2954
fixed vertical padding on line chart, made correction on yaxis title …
eddiman Mar 16, 2021
ee9b472
fixed font sizing
eddiman Mar 17, 2021
515e246
Merge pull request #13 from NDLANO/feature/distance-fixing
eddiman Mar 18, 2021
644cc40
Merge branch 'master' of https://github.com/h5p/h5p-chart into h5p-ma…
boyum May 28, 2021
2e0a1b4
Merge pull request #15 from NDLANO/h5p-master
boyum May 28, 2021
cac84e9
adding color palette to charts
Jun 22, 2021
4366394
Merge pull request #16 from NDLANO/add-color-palette-to-charts
EivinS Jun 22, 2021
4e3a9c7
making every chart-type scale by default
Jun 22, 2021
3acc258
Merge pull request #17 from NDLANO/fix/scale-chart
EivinS Jun 23, 2021
ab4bcb2
Properly fork to NDLAChart
otacke Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions bar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*global d3*/
H5P.Chart.BarChart = (function () {
H5P.NDLAChart.BarChart = (function () {

/**
* Creates a bar chart from the given data set.
Expand Down Expand Up @@ -94,8 +94,7 @@ H5P.Chart.BarChart = (function () {
var height = h - tickSize - lineHeight; // Add space for labels below

// Update SVG size
svg.attr("width", width)
.attr("height", h);
svg.attr('viewBox', `0 0 ${width} ${h}`);

// Update scales
xScale.rangeRoundBands([0, width], 0.05);
Expand Down Expand Up @@ -125,7 +124,7 @@ H5P.Chart.BarChart = (function () {
return height - yScale(d.value) + lineHeight;
});

// Hide ticks from readspeakers, the entire rectangle is already labelled
// Hide ticks from screen readers, the entire rectangle is already labelled
xAxisG.selectAll("text").attr("aria-hidden", true);
};
}
Expand Down
48 changes: 45 additions & 3 deletions chart.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.h5p-chart svg {
display: block;
margin: 0 auto;
}
.h5p-chart-chart {
font-size: 0.75em;
font-size: 12px;
font-size: min(16px, 0.9em);
width: 100%;
height: 100%;
}
.h5p-chart-bar {
width: 100%;
Expand Down Expand Up @@ -31,3 +32,44 @@
height:1px;
overflow:hidden;
}

.h5p-chart .text-rect {
fill: black;
opacity: 0.7;
}


.h5p-chart circle:focus, .h5p-chart .bar:focus {
outline: dodgerblue 2px solid;
}

.h5p-chart .line-path {
fill: none;
stroke-width: 2px;
}

.h5p-chart .chart-title {
font-size: 1.5em;
font-weight: bold;
}

.h5p-chart .y-axis .tick line {
stroke: black;
opacity: 0.4;
}

.h5p-chart .axis-title {
font-size: 1.3em;;
font-weight: bold;
}
.h5p-chart text {
font-size: 1.1em;;
}
.h5p-chart .text-node {
fill: white;
font-size: 1.2em;
dominant-baseline: central;
}
.h5p-chart .y-axis path {
stroke-width: 0;
}
30 changes: 24 additions & 6 deletions chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @external {jQuery} $ H5P.jQuery
* @external {EventDispatcher} EventDispatcher H5P.EventDispatcher
*/
H5P.Chart = (function ($, EventDispatcher) {
H5P.NDLAChart = (function ($, EventDispatcher) {

/**
* Initialize module.
Expand Down Expand Up @@ -34,8 +34,8 @@ H5P.Chart = (function ($, EventDispatcher) {
self.params.listOfTypes = [
{
text: 'Cat',
value: 1,
color: '#D3D3D3',
value: 4,
color: '#fbb033',
fontColor: '#000'
},
{
Expand All @@ -53,15 +53,33 @@ H5P.Chart = (function ($, EventDispatcher) {
];
}

// Set the figure definition for readspeakers if it doesn't exist
// Set the figure definition for screen readers if it doesn't exist
if (!self.params.figureDefinition) {
self.params.figureDefinition = "Chart";
}

// Keep track of type.
self.type = (self.params.graphMode === 'pieChart' ? 'Pie' : 'Bar');
self.type = getChartType(self.params.graphMode);
}

function getChartType(graphMode) {
switch (graphMode) {
case 'pieChart':
return 'Pie';

case 'barChart':
return 'Bar';

case 'extendedBarChart':
return 'ExtendedBar';

case 'lineChart':
return 'Line';

default:
return 'Pie';
}
}
// Inheritance
Chart.prototype = Object.create(EventDispatcher.prototype);
Chart.prototype.constructor = Chart;
Expand Down Expand Up @@ -106,7 +124,7 @@ H5P.Chart = (function ($, EventDispatcher) {
self.$wrapper = $('<div/>', {
'class': 'h5p-chart-chart h5p-chart-' + self.type.toLowerCase()
});
self.chart = new H5P.Chart[self.type + 'Chart'](self.params, self.$wrapper);
self.chart = new H5P.NDLAChart[self.type + 'Chart'](self.params, self.$wrapper);
}

// Prepare container
Expand Down
Loading