@classic-homes/charts-svelte 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,10 @@
14
14
  buildTooltip,
15
15
  categoryTable,
16
16
  chartFormatters,
17
+ forecastStart,
18
+ forecastTagLookup,
19
+ withForecastLines,
20
+ withForecastPoints,
17
21
  colorWithAlpha,
18
22
  generateAreaChartDescription,
19
23
  getChartColors,
@@ -124,11 +128,14 @@
124
128
  return {
125
129
  name: source.name,
126
130
  type: 'line',
127
- data: withPointLabels(
128
- pairWithCategories(data.categories, plotted[index].data, xAxisConfig?.type),
129
- source.labels,
130
- formatters.label,
131
- { position: 'top' }
131
+ data: withForecastPoints(
132
+ withPointLabels(
133
+ pairWithCategories(data.categories, plotted[index].data, xAxisConfig?.type),
134
+ source.labels,
135
+ formatters.label,
136
+ { position: 'top' }
137
+ ),
138
+ source
132
139
  ),
133
140
  smooth,
134
141
  connectNulls,
@@ -151,7 +158,10 @@
151
158
  emphasis: {
152
159
  focus: 'series',
153
160
  },
154
- showSymbol,
161
+ // Forecast points show even when the others are hidden (size 0)
162
+ ...(forecastStart(source) === undefined
163
+ ? { showSymbol }
164
+ : { showSymbol: true, symbolSize: showSymbol ? 4 : 0 }),
155
165
  };
156
166
  });
157
167
 
@@ -183,6 +193,7 @@
183
193
  formatter: tooltipFormatter,
184
194
  valueFormatter: formatters.tooltip,
185
195
  getLabel,
196
+ forecastTag: forecastTagLookup(data.series),
186
197
  }
187
198
  ),
188
199
  legend: buildLegend(
@@ -209,12 +220,20 @@
209
220
  },
210
221
  formatters.axis(yAxisConfig)
211
222
  ),
212
- series: withReferenceMarks(series, referenceLines, referenceBands, {
213
- valueAxis: 'y',
214
- format: formatters.format,
215
- color: chartColors.reference,
216
- bandColor: chartColors.referenceBand,
217
- }),
223
+ series: withForecastLines(
224
+ withReferenceMarks(series, referenceLines, referenceBands, {
225
+ valueAxis: 'y',
226
+ format: formatters.format,
227
+ color: chartColors.reference,
228
+ bandColor: chartColors.referenceBand,
229
+ }),
230
+ data.series,
231
+ {
232
+ colors: data.series.map(
233
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
234
+ ),
235
+ }
236
+ ),
218
237
  } as EChartsOption,
219
238
  optionOverride
220
239
  );
@@ -16,6 +16,8 @@
16
16
  buildTooltip,
17
17
  categoryTable,
18
18
  chartFormatters,
19
+ forecastTagLookup,
20
+ withForecastBars,
19
21
  formatValue,
20
22
  generateBarChartDescription,
21
23
  getChartColors,
@@ -148,11 +150,15 @@
148
150
  const series = data.series.map((source, index) => ({
149
151
  name: source.name,
150
152
  type: 'bar',
151
- data: withPointLabels(
152
- pairWithCategories(data.categories, plotted[index].data, categoryAxisType),
153
- source.labels,
154
- formatters.label,
155
- { position: labelPosition }
153
+ data: withForecastBars(
154
+ withPointLabels(
155
+ pairWithCategories(data.categories, plotted[index].data, categoryAxisType),
156
+ source.labels,
157
+ formatters.label,
158
+ { position: labelPosition }
159
+ ),
160
+ source,
161
+ source.color || chartColors.series[index % chartColors.series.length]
156
162
  ),
157
163
  stack: stackIds[index],
158
164
  itemStyle: {
@@ -217,6 +223,7 @@
217
223
  formatter: tooltipFormatter,
218
224
  valueFormatter: formatters.tooltip,
219
225
  getLabel,
226
+ forecastTag: forecastTagLookup(data.series),
220
227
  }
221
228
  ),
222
229
  legend: buildLegend(
@@ -14,6 +14,10 @@
14
14
  buildTooltip,
15
15
  categoryTable,
16
16
  chartFormatters,
17
+ forecastStart,
18
+ forecastTagLookup,
19
+ withForecastLines,
20
+ withForecastPoints,
17
21
  generateLineChartDescription,
18
22
  getChartColors,
19
23
  hasPointLabels,
@@ -121,14 +125,19 @@
121
125
  const series = data.series.map((source, index) => ({
122
126
  name: source.name,
123
127
  type: 'line',
124
- data: withPointLabels(
125
- pairWithCategories(data.categories, plotted[index].data, xAxisConfig?.type),
126
- source.labels,
127
- formatters.label,
128
- { position: 'top' }
128
+ data: withForecastPoints(
129
+ withPointLabels(
130
+ pairWithCategories(data.categories, plotted[index].data, xAxisConfig?.type),
131
+ source.labels,
132
+ formatters.label,
133
+ { position: 'top' }
134
+ ),
135
+ source,
136
+ showDataPoints ? 6 : 0
129
137
  ),
130
138
  smooth,
131
- showSymbol,
139
+ // Forecast points show even when the others are hidden (size 0)
140
+ showSymbol: showSymbol || forecastStart(source) !== undefined,
132
141
  symbolSize: showDataPoints ? 6 : 0,
133
142
  connectNulls,
134
143
  stack: source.stack ?? (stacked ? 'Total' : undefined),
@@ -172,6 +181,7 @@
172
181
  formatter: tooltipFormatter,
173
182
  valueFormatter: formatters.tooltip,
174
183
  getLabel,
184
+ forecastTag: forecastTagLookup(data.series),
175
185
  }
176
186
  ),
177
187
  legend: buildLegend(
@@ -201,12 +211,20 @@
201
211
  },
202
212
  formatters.axis(yAxisConfig)
203
213
  ),
204
- series: withReferenceMarks(series, referenceLines, referenceBands, {
205
- valueAxis: 'y',
206
- format: formatters.format,
207
- color: chartColors.reference,
208
- bandColor: chartColors.referenceBand,
209
- }),
214
+ series: withForecastLines(
215
+ withReferenceMarks(series, referenceLines, referenceBands, {
216
+ valueAxis: 'y',
217
+ format: formatters.format,
218
+ color: chartColors.reference,
219
+ bandColor: chartColors.referenceBand,
220
+ }),
221
+ data.series,
222
+ {
223
+ colors: data.series.map(
224
+ (s, i) => s.color || chartColors.series[i % chartColors.series.length]
225
+ ),
226
+ }
227
+ ),
210
228
  } as EChartsOption,
211
229
  optionOverride
212
230
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classic-homes/charts-svelte",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Svelte ECharts components for Classic Theme",
5
5
  "type": "module",
6
6
  "svelte": "./dist/lib/index.js",